You copied the Doc URL to your clipboard.

11.71 --library=name

Enables the linker to search a static library without you having specifying the full library filename on the command-line.



Links with the static library, libname.a.


The linker searches either a dynamic library,, or a static library, libname.a, depending on whether dynamic library searching is enabled at that point on the command line:

  • If dynamic linking is enabled, the linker dynamically links with the library,

  • If dynamic linking is disabled it links with the static library, libname.a.

If you specify the --[no_]search_dynamic_libraries option, it applies to the following --library options up until the next --[no_]search_dynamic_libraries option.

References to the shared library are added to the image and resolved to the library by the dynamic loader at runtime. The order that references are resolved to libraries is the order that you specify the libraries on the command line. This is also the order that the dependencies are resolved by the dynamic linker. You can specify the runtime location of libraries using the --runpath option.


Dynamic linking is enabled by default. Use the --[no_]search_dynamic_libraries option to control the searching of dynamic or static libraries.


The following example shows how to search for libfoo.a before libbar.a:

--library=foo --library=bar

Related reference