The Archiver or Librarian

An archiver is a program which allows you to store a set of related object (.o) files together in one archive (.a) file for convenient searching and inclusion by the linker. The archiver for the GNU compiler suite is called ar.

Using ar is pretty simple. Generally using the following form of the command line is enough:

ar -ru libfoobar.a foo.o bar.o

That replaces (-r) the copies of foo.o and bar.o in the library libfoobar.a with the files of the same name. If the library does not exist it creates a new one and if either foo.o or bar.o are not in the library to start with it adds them. The u option tells ar to check that the files foo.o and bar.o are newer than the copies stored in the library (if any) before copying them into the library.

For instructions on including libraries in programs see the section on the linker.