GCC

Ar and Nm

Several compiled modules (or object files) can be grouped into a single file, the so called library or archive. This is the method of choice to make software available to programmers who build on the provided functionality.

An archive from a list of several modules is produced with the ar command:

ar -crs libName.a moduleA.o moduleB.o ...

A library behaves like a single module. To link with the library, we just need to add -lName to the linkage line.

In case one needs to know the contents of an archive, the nm command lists the set of stored modules and functions.

List the symbol’s names:

nm libName.a        (Mac: nm -j libName.a)

Or just list the undefined symbols:

nm -u libName.a


Use Cases | | gdb

Options: