Static linking makes libraries part of the resulting executable file. Dynamic linking keeps these libraries as separate files. Dynamic and static linking can be compared in a number of ways:

We have covered how to build a shared library, how to link with it, and how to resolve the most common loader issues with shared libraries - as well as the positives and negatives of different approaches. This tutorial explains: Steps to create/build static and dynamic (shared) libraries using gcc in c program on linux platform. Static linking is performed at compile time while the dynamic linking is performed รขโ‚ฌยฆ Is it possible to tell the gcc driver directly which libraries should be linked statically? I know that if a certain library exists only in static versions it'll use it without -wl,-bstatic, but i want to imply รขโ‚ฌยฆ If libasan is available as a shared library, and the -static option is not used, then this links against the shared version of libasan.

Is it possible to tell the gcc driver directly which libraries should be linked statically? I know that if a certain library exists only in static versions it'll use it without -wl,-bstatic, but i want to imply รขโ‚ฌยฆ If libasan is available as a shared library, and the -static option is not used, then this links against the shared version of libasan. The -static-libasan option directs the gcc driver to link libasan statically, รขโ‚ฌยฆ