how to link static library into dynamic library in gcc

Static libraries have special rules when it comes to linking. An object from the static library will only be added to the binary if the object provides an unresolved symbol. On Linux, you can change that behavior with the –whole-archive linker option: g++ -Wl,–whole-archive some_static_lib.a -Wl,–no-whole-archive

Use both static and dynamically linked libraries in gcc

Statically linking against any system library, and especially against libc, on modern UNIX or Linux systems makes the binary significantly less portable. Just don’t do it. Instead, use backward compatibility (binaries linked on an older system continue to run on all newer ones) to your advantage, either by linking your binary on an old system … Read more

CUDA incompatible with my gcc version

As already pointed out, nvcc depends on gcc 4.4. It is possible to configure nvcc to use the correct version of gcc without passing any compiler parameters by adding softlinks to the bin directory created with the nvcc install. The default cuda binary directory (the installation default) is /usr/local/cuda/bin, adding a softlink to the correct … Read more

I don’t understand -Wl,-rpath -Wl,

The -Wl,xxx option for gcc passes a comma-separated list of tokens as a space-separated list of arguments to the linker. So gcc -Wl,aaa,bbb,ccc eventually becomes a linker call ld aaa bbb ccc In your case, you want to say “ld -rpath .“, so you pass this to gcc as -Wl,-rpath,. Alternatively, you can specify repeat … Read more