Kenwood HP 9000 Personal Computer User Manual


 
Chapter 5 131
Creating and Using Libraries
Creating Archive Libraries
Creating Archive Libraries
Two steps are required to create an archive library:
1. Compile one or more source files to create object files containing
relocatable object code.
2. Combine these object files into a single archive library file with the
ar command.
Shown below are the commands you would use to create an archive
library called libunits.a:
cc -Aa -c length.c volume.c mass.c
ar r libunits.a length.o volume.o mass.o
These steps are described in detail in “Overview of Creating an Archive
Library”.
Other topics relevant to archive libraries are:
“Contents of an Archive File”
“Example of Creating an Archive Library”
“Replacing, Adding, and Deleting an Object Module”
“Summary of Keys to the ar(1) Command”
“Archive Library Location”
Overview of Creating an Archive Library
To create an archive library:
1. Create one or more object files containing relocatable object code.
Typically, each object file contains one function, procedure, or data
structure, but an object file could have multiple routines and data.
2. Combine these object files into a single archive library file with the ar
command. Invoke ar with the r key.
(“Keys” are like command line options, except that they do not require
a preceding -.)