static-libraries

What is the Microsoft Visual Studio equivalent to GCC ld option --whole-archive

余生颓废 提交于 2019-11-26 21:28:42
问题 When linking a static library against an executable, unreferenced symbols are normally discarded. In my case some otherwise unused objects are used to register their respective classes into a factory and if the objects are discarded, this registration fails. Under Unix where we use gcc, I can pass the flag --whole-archive to the linker ld (see excerpt from ld documentation below), which makes ld not discard any objects. Is there anything like this for Visual C++? --whole-archive For each

core data in a static library for the iPhone

天涯浪子 提交于 2019-11-26 21:24:02
I've built a static library that makes heavy use of the Core Data framework. I can successfully use the library in my external project, but ONLY if I include the .xcdatamodel file in the main project. That is less than ideal, since the point of the library was to hide implementation details to the maximum possible. In a separate question , I was informed that I cannot bundle resources with a library (which makes complete sense to me now). So is there a way to programatically allow the model to be 'discovered' without having to include the model in the main project? I also created my own static

How to resolve 'unrecognized selector sent to instance'?

馋奶兔 提交于 2019-11-26 20:19:35
问题 In the AppDelegate, I'm alloc'ing an instance defined in a static library. This instance has an NSString property set a "copy". When I access the string property on this instance, the app crashes with 'unrecognized selector sent to instance'. Xcode provides a code hint for the property, which means it is known in the calling app. The particular class is compiled into the static library target. What am I missing? Adding some code. //static library //ClassA.h @interface ClassA : NSObject { ...

How can I use an .a static library in swift?

↘锁芯ラ 提交于 2019-11-26 20:14:07
I want to use my webrtc .a static library in swift. Can you help please? I read you can´t use static libraries in swift, is that true? Have you fixed this problem you asked? I meet this problem on today too, and I've fixed it just a moment. If you don't have fixed this problem, you can try the below steps: p.s.: the 2 projects are in the same workspace (the static lib project and the App project), the static lib project is build before the app project. The workspace structure as the pic shows: In the static lib project, all the .h files are need add to "Build Phases/Copy Files": Drag the

How to compile a static library in linux?

為{幸葍}努か 提交于 2019-11-26 19:19:27
I have a question: How to compile a static library in linux with gcc, i.e. I need to compile my source code into a file named out.a. Is it sufficient to simply compile with the command gcc -o out.a out.c ? I'm not quite familiar with gcc, hope anyone can give me a hand. See Creating a shared and static library with the gnu compiler [gcc] gcc -c -o out.o out.c -c means to create an intermediary object file, rather than an executable. ar rcs libout.a out.o This creates the static library. r means to insert with replacement, c means to create a new archive, and s means to write an index. As

gcc will not properly include math.h

醉酒当歌 提交于 2019-11-26 18:50:26
Here is a minimal example outlining my problem test.c: #include <stdio.h> #include <math.h> main () { fmod ( 3, 2 ); } And here is the command I am issuing to compile test.c gcc -lm test.c -o test And here is the output I get when I issue the above command /tmp/ccQmRk99.o: In function `main': test.c:(.text+0x3e): undefined reference to `fmod' collect2: ld returned 1 exit status I get the same output if instead I use cc . I am using the following version of gcc gcc-4.6.real (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 Any ideas why my program won't compile? Scott Wales The problem is coming from the

How to static link on OS X

自作多情 提交于 2019-11-26 18:44:24
I'm trying to link to a static library on OS X. I used the -static flag in the gcc command but I get the following error message: ld_classic: can't locate file for: -lcrt0.o collect2: ld returned 1 exit status I looked in the man pages and it reads something like: This option will not work on Mac OS X unless all libraries (including libgcc.a) have also been compiled with -static. Since neither a static version of libSystem.dylib nor crt0.o are provided, this option is not useful to most people. Is there another way to link to this static library? Employed Russian In order to link to an archive

C++ static variable in .lib does not initialize

随声附和 提交于 2019-11-26 18:33:01
问题 I have static library (.lib) in VS2010 and am linking it to my test project. The lib has a factory that I create using the below MACRO: #define REGISTER_FACTORY(mType, my_class) \ class Factory##my_class : public CAbstractFactory\ {\ public:\ Factory##my_class() : CAbstractFactory(mType){}\ CBaseClass *Create()\ { return new my_class(); }\ };\ static Factory##my_class StaticFactory##my_class; What is supposed to happen is that in the CAbstractFactory the new factory gets registered by mtype .

Linking static libraries, that share another static library

穿精又带淫゛_ 提交于 2019-11-26 17:41:40
问题 I currently have a single Xcode project for a very large code base, I'll call it Project X , which I am dividing into a bunch of sub projects ( Projects A, B, C ). So far, each of these projects compiles, on their own, just fine. They all produce static libraries. Project B and Project C are dependent on the static library produced by Project A in order to build. I have another xcode project, Project Z , that requires the static libraries produced by Projects B and C . Herein lies the problem

static linking only some libraries

。_饼干妹妹 提交于 2019-11-26 16:59:49
How can I statically link only a some specific libraries to my binary when linking with GCC? gcc ... -static ... tries to statically link all the linked libraries, but I haven't got the static version of some of them (eg: libX11). Let_Me_Be gcc -lsome_dynamic_lib code.c some_static_lib.a You could also use ld option -Bdynamic gcc <objectfiles> -static -lstatic1 -lstatic2 -Wl,-Bdynamic -ldynamic1 -ldynamic2 All libraries after it (including system ones linked by gcc automatically) will be linked dynamically. wgodoy gcc objectfiles -o program -Wl,-Bstatic -ls1 -ls2 -Wl,-Bdynamic -ld1 -ld2 you