8.3.8 Library Option
The --library name (-l
name)
option searches for a library archive with the name
name
.
This option adds library archive file called name
to the list of files to link. This option may
be used any number of times. The linker will search its path-list for occurrences of
libname.a
for every
name
specified. The linker will
search a library archive only once, at the location where it is specified on the command
line. If the archive defines a symbol that was undefined in some object that appeared
before the archive on the command line, the linker will include the appropriate file(s)
from the archive. However, an undefined symbol in an object appearing later on the command
line will not cause the linker to search the archive again. See the -(
option for a way to force the linker to search archives
multiple times. You may list the same archive multiple times on the command line.
If the format of the library archive file is not recognized, the linker will ignore it. Therefore, a version mismatch between libraries and the linker may result in “undefined symbol” errors.