Static linking only some libraries

gcclinkerstatic-libraries

How can I statically link only a some specific libraries to my binary when linking with GCC?

gcc ... -static ... tries to statically link all the linked libraries, but I haven't got the static version of some of them (eg: libX11).

Best Answer

gcc -lsome_dynamic_lib code.c some_static_lib.a