Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I specify that library X must be linked statically?

Tags:

People also ask

What does it mean to be statically linked?

Static linking means that the code for all routines called by your program becomes part of the executable file. Statically linked programs can be moved to run on systems without the XL Fortran runtime libraries.

How are libraries linked?

Dynamic libraries are linked during the execution of the final executable. Only the name of the dynamic library is placed in the final executable. The actual linking happens during runtime, when both executable and library are placed in the main memory.


I have a piece of software which is linked against several libraries. They all exists in a dynamic (.so) and a static (.a) version. By default, when using g++ it chooses the dynamic version of the libraries and that's fine with me.

However, one of them absolutely needs to be linked statically. I thought about using -static but then it uses a static version for all of them, which is not what I want.

How can I specify that library X must be linked statically, while the others continue to be linked against the shared version of the libs ?