Creating libraries of object module

Gordon C. Galligher gorpong at telxon.uucp
Sat Mar 3 06:37:28 AEST 1990


In article <12233 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>In article <34230 at news.Think.COM> saroff at wotan.think.com.UUCP (steven saroff) writes:
>>How does one create personal libraries or archives of object modules to
>>like to.  I want to have a library of various useful sub program, and
>>just link to them with a -l or something akin to it when I am compiling
>>some larger code.
>
>All that the "ld" or "cc" option "-lxxx" option does is to in effect
>expand in-line to the pathname /usr/lib/libxxx.a.  You can always
>specify the pathname of any library archive that you wish to be
>searched at that point in the link-editing process.  Such archives
>are created and maintained via the "ar" utility, which is described

Doug is absolutely correct about the 'ar' utility.  Another thing which he
didn't mention about the -l flag is the ability to use the -L_path_ flag.
This flag, when given, causes the loader (ld(1)) to search that directory
for libraries of the form libxxxx.a also.  This gives you the ability to
have a directory of libraries ($HOME/lib for example) and then on your cc
or ld command lines just give:
	 cc -o file .o_files -L$HOME/lib -lm -lmylib1 -lmylib2
Just another way to do the exact same thing.  This gives you a shortcut if
you happen to have more than one "local" library you will be using.

		-- Gordon.

Gordon C. Galligher  <|> ..!uunet!telxon!gorpong <|> telxon!gorpong at uunet.uu.net
Telxon Corporation   <|> "I am attempting, ma'am, to make a mnemonic memory
Akron, Ohio, 44313   <|> circuit out of stone knives and bearskins"  - Spock
(216) 867-3700 (3512)<|>	_City on the Edge of Forever_



More information about the Comp.unix.questions mailing list