If you want to statically link one or two libraries to the rest, including system libraries, being dynamic, it is often easier to just reference the static library by its full name. Those. instead of using -l and -l to get g ++ to resolve the library from what it finds, just add the full path to the library as input. By taking the g ++ command above to bind the main program of the main.o application with static libz, libfoo, dynamic libbar, libglib, etc .:
g++ main.o /usr/lib/libz.a /usr/lib/libfoo.a -lbar
Edit August 3, 17: I just read this answer, which is more than -l: and offers an alternative way ( -l: to specify the library directly.
stanthomas Oct 03 '16 at 22:53 on 2016-10-03 22:53
source share