static-libraries

ld linker question: the --whole-archive option

房东的猫 提交于 2019-11-26 05:56:18
问题 The only real use of the --whole-archive linker option that I have seen is in creating shared libraries from static ones. Recently I came across Makefile(s) which always use this option when linking with in house static libraries. This of course causes the executables to unnecessarily pull in unreferenced object code. My reaction to this was that this is plain wrong, am I missing something here ? The second question I have has to do with something I read regarding the whole-archive option but

static linking only some libraries

只愿长相守 提交于 2019-11-26 04:59:58
问题 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). 回答1: gcc -lsome_dynamic_lib code.c some_static_lib.a 回答2: 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

How to apply -fvisibility option to symbols in static libraries?

僤鯓⒐⒋嵵緔 提交于 2019-11-26 03:52:33
问题 I have a shared library project that is built from 4 static libraries ( .a ) and one object ( .o ) file. I am trying to add the -fvisibility=hidden option to restrict symbols in the output to only those that I mark in the source with an __attribute__. I\'ve added the -fvisibility=hidden option to the compile options for the .so project (which covers the .o file) and for the .a projects. The symbols in the object file are removed as expected from the final .so . However the symbols from the .a

Telling gcc directly to link a library statically

二次信任 提交于 2019-11-26 03:35:28
问题 It feels strange to me to use -Wl,-Bstatic in order to tell gcc which libraries I want to link with statically. After all I\'m telling gcc directly all other information about linking with libraries ( -Ldir , -llibname ). Is it possible to tell the gcc driver directly which libraries should be linked statically? Clarification: I know that if a certain library exists only in static versions it\'ll use it without -Wl,-Bstatic , but I want to imply gcc to prefer the static library. I also know

File is universal (three slices), but it does not contain a(n) ARMv7-s slice error for static libraries on iOS, anyway to bypass?

穿精又带淫゛_ 提交于 2019-11-26 02:04:45
问题 I upgraded Xcode version and when using external static libraries, I get this message: ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /file/location for architecture armv7s clang: error: linker command failed with exit code 1 (use -v to see invocation) Is there any way to bypass this and add support to the library if the developer of the library hasn\'t updated their library yet? 回答1: If you want to remove the support for any architecture, for example, ARMv7-s in

“undefined reference to” errors when linking static C library with C++ code

故事扮演 提交于 2019-11-26 00:48:31
问题 I have a test file (just for the link test) where I overload the new / delete operators with my own malloc / free library called libxmalloc.a . But I keep getting \"undefined reference to\" error as following when linking the static library, even I change the order of test.o and -lxmalloc . But everything works well with other C programs linking this library. I\'m so confused with this issue and appreciate any clue. Error Msg: g++ -m64 -O3 -I/usr/include/ethos -I/usr/include/nacl/x86_64 -c -o

Library? Static? Dynamic? Or Framework? Project inside another project

折月煮酒 提交于 2019-11-26 00:39:49
问题 I have an existing iOS app and want to add a large chunk of code that I\'ve been developing as another project just for ease of testing. The new chunk basically deals with saving an image to various sharing services, etc.. Because that sharing code needs a lot of testing and future updating, I was wondering what the best way to incorporate that code chunk into my existing app. I don\'t know if it should be a static library, dynamic library or a framework, and honestly, I\'m not really sure

Difference between static and shared libraries?

那年仲夏 提交于 2019-11-26 00:29:27
问题 What is the difference between static and shared libraries? I use Eclipse and there are several project types including Static Libraries and Shared Libraries? Does one have an advantage over the other? 回答1: Shared libraries are .so (or in Windows .dll, or in OS X .dylib) files. All the code relating to the library is in this file, and it is referenced by programs using it at run-time. A program using a shared library only makes reference to the code that it uses in the shared library. Static

How to merge two “ar” static libraries into one?

邮差的信 提交于 2019-11-26 00:25:22
问题 I have 2 static Linux libraries, created by ar cr , libabc.a and libxyz.a . I want to merge them into one static library libaz.a . How can I do this. I want to create a merged static library, not to give both libraries to final link of applications. 回答1: You can extract the object from both the .a files and create your .a file using the extracted .o s: ar -x libabc.a ar -x libxyz.a ar -c libaz.a *.o 回答2: There are at least three ways to do this natively . The first and most portable way is to

Objective-C categories in static library

眉间皱痕 提交于 2019-11-26 00:13:47
问题 Can you guide me how to properly link static library to iPhone project. I use static library project added to app project as direct dependency (target -> general -> direct dependencies) and all works OK, but categories. A category defined in static library is not working in app. So my question is how to add static library with some categories into other project? And in general, what is best practice to use in app project code from other projects? 回答1: Solution: As of Xcode 4.2, you only need