An archive library contains one or
more object files and is created with the ar
command. When linking an object file with an archive library, ld
searches the library for global definitions that match up with external
references in the object file. If a match is found, ld
copies the object file containing the global definition from the
library into the a.out
file. In short, any routines or data a program needs from the library
are copied into the resulting a.out
file.
Example |
 |
For example, in 32-bit mode, suppose you write a C program
that calls printf
from the libc
library. Figure 5-1 “Linking with an Archive
Library ” shows
how the resulting a.out
file would look if you linked the program with the archive version
of libc.