Programming Utilities Guide

Libraries, Members, and Symbols

An object library is a set of object files contained in an ar library archive (see ar(1) and lorder(1) in the SunOS reference Manual for details about library archive files.) Various languages make use of object libraries to store compiled functions of general utility, such as those in the C library.

ar reads in a set of one or more files to create a library. Each member contains the text of one file, preceded by a header. The member header contains information from the file directory entry, including the modification time. This allows make to treat the library member as a separate entity for dependency checking.

When you compile a program that uses functions from an object library (specifying the proper library either by filename, or with the -l option to cc), the link editor selects and links with the library member that contains a needed symbol.

You can use ar to generate a symbol table for a library of object files. ld requires this table in order to provide random access to symbols within the library--to locate and link object files in which functions are defined. You can also use lorder and tsort ahead of time to put members in calling order within the library. (See ar(1) and lorder(1) for details.) For very large libraries, it is a good idea to do both.