Kenwood HP 9000 Personal Computer User Manual


 
132 Chapter 5
Creating and Using Libraries
Creating Archive Libraries
Figure 5-4 summarizes the procedure for creating archive libraries from
three C source files (file1.c, file2.c, and file3.c). The process is
identical for other languages, except that you would use a different
compiler.
Figure 5-4 Creating an Archive Library
Contents of an Archive File
An archive library file consists of four main pieces:
1. a header string, "!<arch>\n", identifying the file as an archive file
created by ar (\n represents the newline character)
2. a symbol table, used by the linker and other commands to find the
location, size, and other information for each routine or data item
contained in the library
3. an optional string table used by the linker to store file names that
are greater than 15 bytes long (only created if a long file name is
encountered)
4. object modules, one for each object file specified on the ar command
line
To see what object modules a library contains, run ar with the t key,
which displays a table of contents. For example, to view the “table of
contents” for libm.a:
$ ar t /usr/lib/libm.a
Run ar with the t key.