Libraries

Top  Previous  Next

It is often convenient to be able to treat a group of object files as a single unit. For example, the Diamond run-time library comprises many separate object files, but is supplied as a single file containing all of them. As we have seen above, the linker searches libraries for the necessary modules to complete the program being linked.

 

Using a library has several advantages over using a linker command file:


The linker selects from the library file only those modules that are actually referenced elsewhere in the program; the others are not included in the task image file.

Copying a single file to another place is simpler than copying many component object files and making sure that the corresponding linker command file is kept up to date with changes in folder and file names.

Opening just one library file is faster than opening a linker command file and several object files.

Library files are created and maintained by the archiver. Details of this program may be found in the TI documentation.

 

The example below shows a hypothetical graphics library, grafpak.lib, being built from a core graphics module, core.obj, and two device driver modules, tek.obj and hp.obj:

 

» ar6x -a grafpak.lib core.obj tek.obj hp.obj

 

The default extension for the library name is .lib. The archiver does not assume an extension for the object file names; you must specify .obj explicitly for each one.

 

The following example shows how to replace an existing module hp.obj with a different version:

 

» ar6x -r grafpak hp.obj

 

It is probably safer always to use the –r option with the archiver to ensure that only the more recent versions of files are kept.