Telling gcc directly to link a library statically

Use -l: instead of -l. For example -l:libXYZ.a to link with libXYZ.a. Notice the lib and .a are written out, as opposed to -lXYZ which would auto-expand to libXYZ.so/libXYZ.a. It is an option of the GNU ld linker: -l namespec … If namespec is of the form :filename, ld will search the library path for a file called filename, otherwise it will search the library path for a file called libnamespec.a. … on ELF … systems, ld will search a directory … Read more

Static linking vs dynamic linking

Dynamic linking can reduce total resource consumption (if more than one process shares the same library (including the version in “the same”, of course)). I believe this is the argument that drives it its presence in most environments. Here “resources” includes disk space, RAM, and cache space. Of course, if your dynamic linker is insufficiently flexible there is … Read more