dynamic-linking

How to embed a static library into a shared library?

情到浓时终转凉″ 提交于 2019-12-11 00:03:36
问题 On linux I am trying to create a shared library, libbar.so, that embeds a commercial static library (licensing is fine). The commercial library has 4 versions: libfoo-seq.a, libfoo-mt.a, libfoo-seq.so, and libfoo-mt.so (they all provide the same symbols, just the code is sequential/multi-threaded, and the lib is static/shared). Of these four I want my code always to use the sequential foo library, so when I create libbar.so I link together my object files and libfoo-seq.a. The problem is that

Building .so with recursive function in it

≯℡__Kan透↙ 提交于 2019-12-10 18:51:05
问题 During working on some project, I faced the issue that I can't build so library. I have got the error like: relocation R_X86_64_PC32 against symbol '' can not be used when making a shared object; recompile with -fPIC Eventually I managed to find the root cause. And it was recursive function in the library. For example, I have the following well know example: .section .text .globl factorial .type factorial,STT_FUNC factorial: push %rbp mov %rsp,%rbp mov 16(%rbp),%rax cmp $1,%rax je end

Python ctypes and dynamic linking

前提是你 提交于 2019-12-10 17:50:54
问题 I'm writing some libraries in C which contain functions that I want to call from Python via ctypes. I've done this successfully another library, but that library had only very vanilla dependencies (namely fstream , math , malloc , stdio , stdlib ). The other library I'm working on has more complicated dependencies. For example, I'll try to use fftw3 . As a test, I'll just try to compile a simple .cpp file containing: int foo() { void *p = fftw_malloc( sizeof(fftw_complex)*64 ); fftw_free(p);

Same symbols in different libraries and linking order

有些话、适合烂在心里 提交于 2019-12-10 15:41:13
问题 I have 2 libraries: test.1 and test.2 . Both libraries contain a single global extern "C" void f(); function, with different implementations (just a cout for the test). I did the following test: Test 1 Dynamic linking: If I add libtest.1.so and then libtest.2.so in the makefile of the executable and then call f(); in main , libtest.1.so->f() is called. If I change the order in the makefile, libtest.2.so->f() is called Test 2 Static linking: Absolutely the same happens with static libraries

Setting LD_LIBRARY_PATH environment variable for loading a shared library at runtime (g++)

一曲冷凌霜 提交于 2019-12-10 15:23:25
问题 I'm having two problems related to the same issue: I have a shared object saved in `pwd`/lib and while the executable that uses it compiles successfully (by using -l and -L switches), at runtime, it's giving me grief. If I try to run LD_LIBRARY_PATH=/my/absolute/path/to/library/directory ./test it works fine. But if I export LD_LIBRARY_PATH=/my/absolute/path/to/library/directory and do ./test it says that it can't find the shared library. However, if I do LD_LIBRARY_PATH=$LD_LIBRARY_PATH .

How to compile SDL program and run it without DLL

一世执手 提交于 2019-12-10 10:54:24
问题 is it possible to compile SDL library program into exec and run it without having "sdl.dll"? for example let say i wrote sdl program and it works and everything but the thing is to run the program on windows, i need to have "sdl.dll" within the same folder or system folder. is it possible to compile it so that i can just take the exec with me without needing to have "sdl.dll" along with it? i am using visual studio 2010 express. 回答1: Typically the procedure for this kind of stuff is: Download

.so with numerals after that, how to match them in find_library in cmake ? Error in linking shared objects which are found as sub-dependencies

喜欢而已 提交于 2019-12-10 10:36:11
问题 Given ls -lrt /usr/lib/libvpx* results lrwxrwxrwx 1 root root 15 Feb 9 2012 /usr/lib/libvpx.so.1.0 ->libvpx.so.1.0.0 lrwxrwxrwx 1 root root 15 Feb 9 2012 /usr/lib/libvpx.so.1 -> libvpx.so.1.0.0 -rw-r--r-- 1 root root 646120 Feb 9 2012 /usr/lib/libvpx.so.1.0.0 ls -lrt /usr/lib/libschroedinger* results lrwxrwxrwx 1 root root 29 Feb 8 2012 /usr/lib/libschroedinger-1.0.so.0 ->libschroedinger-1.0.so.0.11.0 -rw-r--r-- 1 root root 774044 Feb 8 2012 /usr/lib/libschroedinger-1.0.so.0.11.0 ls -lrt /usr

What's the purpose of copy relocation?

大兔子大兔子 提交于 2019-12-10 09:41:44
问题 BACKGROUND: If an executable file has a external data reference, which is defined in a shared object, the compiler will use copy relocation and place a copy in its .bss section. Copy relocation is detailed in this site: http://www.shrubbery.net/solaris9ab/SUNWdev/LLM/p22.html#CHAPTER4-84604 However, my question is: Is it possible to implement it through GOT, just like the external data reference in shared object? The executable can indirectly accesses this external code through its GOT entry,

Firebase dynamic deep link arrives nil after install

人走茶凉 提交于 2019-12-10 06:21:29
问题 I am attempting to use Firebase to pass deep links into my app that survive install. To test this I am following the steps provided by the Firebase documentation and Firecast video here at about the 12min 40s mark. The steps are as follows: First I delete the app from my device. Then I press the link to open the app store. Then I run my app from xcode. Expected: The dynamicLink.url property will be equal to "https: //www.example.com/data/helloworld" in application:openURL Reality: The

How exactly does gperftools CPU profiler start?

五迷三道 提交于 2019-12-10 02:26:31
问题 gperftools documentation says that libprofiler should be linked into a target program: $ gcc myprogram.c -lprofiler (without changing a code of the program). And then program should be run with a specific environment variable: CPUPROFILE=/tmp/profiler_output ./a.out The question is: how does libprofile have a chance to start and finish a profiler when it is merely loaded, but its functions are not called? There is no constructor function in that library (proof). All occasions of "CPUPROFILE"