Kenwood HP 9000 Personal Computer User Manual


 
Chapter 5 125
Creating and Using Libraries
What are Archive Libraries?
What are Archive Libraries?
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.
NOTE For 32-bit only:
If the only definition referenced in an object file of an archive library is a
common symbol, only that common symbol is copied into the a.out and
not the entire object file. This helps reduce the size of the a.out file.
Example
For example, in 32-bit mode, suppose you write a C program that calls
printf from the libc library. “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.
Figure 5-1 Linking with an Archive Library