shared-libraries

How to build a shared library (.so) without hardcoded full dependency paths?

拜拜、爱过 提交于 2019-11-30 06:42:23
I need to build two 3rd party shared libraries, so their .so files will be reused by other projects. However, after build one of these libraries contains hardcoded path to another. This path is invalid on other machines and causes linker warnings. How can I prevent the full path from being embedded in the resulting .so files? Details: First library source: ~/dev/A Second library source: ~/dev/B Both of them have configure script to generate make files. Library B depends on A . So, first I build A : $ ~/dev/A/configure --prefix=~/dev/A-install $ make && make install Then I build B : $ ~/dev/B

Python runtime_library_dirs doesn't work on Mac

混江龙づ霸主 提交于 2019-11-30 05:42:49
I have a Python extension module that needs to link against some dynamic libraries at runtime, so I need to tell it where to look for them. I'm doing this by specifying runtime_library_dirs in my setup.py. This works fine on Linux, but seems to have no effect on Mac. I get an ImportError when I try to import my module, and the only way I've found to make it go away is to add the library directory to DYLD_LIBRARY_PATH before starting python. What do I need to do to make this work? I finally figured this out. The solution has two parts. First, setup.py needs to use extra_link_args to tell the

Why should I recompile an entire program just for a library update?

浪尽此生 提交于 2019-11-30 05:33:43
With respect to the following link: http://www.archlinux.org/news/libpnglibtiff-rebuilds-move-from-testing/ Could someone explain to me why a program should be rebuilt after one of its libraries has been updated? How does that make any sense since the "main" file is not changed at all? If the signatures of the functions involved haven't changed, then "rebuilding" the program means that the object files must be linked again. You shouldn't need to compile them again. An API is contract that describes the interface to the public functions in a library. When the compiler generates code, it needs

How does gcc `-shared` option affect the output?

心已入冬 提交于 2019-11-30 05:24:35
问题 Technically, in terms of file content, what is the difference between the output of gcc -fPIC -shared src.c and gcc -fPIC src.c ? Assume that int main(int, char**) is defined in src.c so that both compilations succeed. But executing the a.out generated by gcc -shared src.c , as expected, gave the following error: -bash: ./a_shared.out: cannot execute binary file Even if there is a main function it it. Also, how can I inspect the difference in the output files using tools like otool or objdump

Static library & Dynamic library : Confusion

依然范特西╮ 提交于 2019-11-30 05:23:18
I need little clarification in this area. I feel that the terms Static library & Dynamic Library are not correct. lib1.o + lib2.o + lib3.o --> "LinkerOutputFile"(executable or library). If this "LinkerOutputFile" contains the code of all the files lib1.o , lib2.o, lib3.o then its said that "LinkerOutputFile" is satically-linked "LinkerOutputFile"(executable or library). (or) If "LinkerOutputFile" just contains references & other information about to lib1.o, lib2.o, lib3.o without containing the code of these lib*.o files. Then its said that "LinkerOutputFile" Dynamically linked. How does this

Tool for Library Dependency

社会主义新天地 提交于 2019-11-30 05:16:55
I'm looking for the tool / command on Unix platform to detect the library dependencies of the .so and .o files. I have already used the ldd / nm / truss , but I don't know the proper approach to detect library dependencies. It depends on what exactly is meant by "detect library dependencies". The ldd command works on shared libraries, not just on executables. It will display the dependencies of a shared library declared when the library was built: $ ldd /usr/lib/libgtk-3.so linux-vdso.so.1 (0x00007ffff8fff000) libgdk-3.so.0 => /usr/lib/libgdk-3.so.0 (0x00007f43fcf47000) libgmodule-2.0.so.0 =>

How to force using local shared libraries over system libraries?

拟墨画扇 提交于 2019-11-30 05:04:34
How can I force using a local library over the system library in linux? I linked my executable explicitly to some .so files in my project/lib directory e.g. (../lib/libluajit.so). Running my executable under gdb or using ldd shows that it still uses the system libluajit-5.1.so.2 I then set LD_LIBRARY_PATH to my project/lib directory and exported it, then ran my executable. Somehow it's still picking up the system library (confirmed by both gdb and ldd) I'd like to know how that's even possible, and what I can do to force it to use the local libluajit.so in my project/lib directory. When you

Xcode “ld: library not found […] for architecture x86_64”

风格不统一 提交于 2019-11-30 05:01:38
问题 I want to include libgpg-error and libgcrypt in my swift-project and created the following module.modulemaps: libgpgerror: module libgpgerror { header "/Volumes/Xcode/Programme/Swifts/KCAnon/KCAnon_Client/Libs/libgpgerror/gpg-error.h" link "'/Volumes/Xcode/Programme/Swifts/KCAnon/KCAnon_Client/Libs/libgpgerror/libgpgerror-1.21.dylib'" export * } libgcrypt: module libgcrypt { header "/Volumes/Xcode/Programme/Swifts/KCAnon/KCAnon_Client/Libs/libgcrypt/gcrypt.h" link "'/Volumes/Xcode/Programme

Returning a shared library symbol table

巧了我就是萌 提交于 2019-11-30 04:58:03
For instance: void* sdl_library = dlopen("libSDL.so", RTLD_LAZY); void* initializer = dlsym(sdl_library,"SDL_Init"); Assuming no errors, initializer will point to the function SD_Init in the shared library libSDK.so. However this requires knowing the symbol "SDL_Init" exists. Is it possibly to query a library for all its symbols? Eg, in this case it would return SDL_Init, the function pointer, and any other symbols exported by libSDL.so. jweyrich There is no libc function to do that. However, you can write one yourself (though the code is somewhat involved). On Linux, dlopen() in fact returns

How to Debug Java -JNI using GDB on linux ?

佐手、 提交于 2019-11-30 03:54:55
Can anyone guide on how to debug a JNI code on Linux using GDB debugger(if possible please suggest other options). -My JNI project when running on Linux is leading to a JVM crash. -The CPP code has been compiled into .so files. -I run the project like this : *java xyz.jar -commandline_args_to_project*. I have the Gdb installed but am not getting how we can debug the project using it. Also do I necessarily need to compile the .cpp files with -g option t debug .so files? Start your java application Look up the pid using top, ps, ... Start gdb with this pid Attach your program code Debug as usual