9. Librarian¶
The librarian makes it possible to combine multiple object files into a single library. This is sometimes called an archiver.
The librarian is a command line tool named nlib. Running it from the command line with the ``–help`` option will give a sign-on message and display accepted options:
Calypsi librarian for none version 5.16
Usage: nlib [--version] [FILE...]
use 'nlib --help' for detailed help
Available options:
--version Display version number
-h,--help Show this help text
The main use-case for a librarian is to build collections of smaller fragments, which can be anything from support routines to full fledged applications. Such collection is called a library, static library or an archive.
9.1. Creating a library¶
To create a library, simply list all object files (.o extension)
and a single output file (.a extension).
$ nlib lib41.a obj1.o obj2.o ashfx.o xtoal.o
The created library is typically used as input to the lnnut linker
by just specifying it on the command line. When linking with a
library, only those section fragments that are actually used are
included in the final output.