Link Archiver

Revision as of 03:21, 7 March 2007 by osdev>Jhawthorn
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:Convert

You have many object files and your linking line for a program in your OS grows longer and longer? GNU AR helps.

It creates archives of object files alongside with a table of the symbols, which each object file (==member) sports.

USAGE: =ar -rcs archive.a obj_fil1.o obj_fil2.o obj_fil3.o obj_fil4.o ... obj_filN.o=

You link your program's object file against =crt0.o= and the =archive.a= file.

Important: If you link other object files besides the library =archive.a=, take care that the =archive.a= is right behind these object files (or have it be the very last file in the list of files to link) - so the linker can resolve the one or other occurrence of a symbol which is covered by some member of the =archive.a= library.

See also the [GNU 'ar' online manual | http://www.gnu.org/software/binutils/manual/html_chapter/binutils_1.html].