[NTLUG:Discuss] file types in /usr/lib

Chris Cox cjcox at acm.org
Tue Nov 28 13:51:54 CST 2006


Richard Geoffrion wrote:
> Richard Geoffrion wrote:
>>What does one call files in the /usr/lib directory that end in ".a"? 
>>What kind of files are they?
>>
>>I know that .so files are Shared Object files.. but what are .a files?
>>
>>  
> Why do I seem to find the answer AFTER I've posted???
> 
> "...They're libraries (collections of .o files, basically). Most 
> libraries live in /usr/lib.  When you specify "-lm" to cc/gcc at link 
> time, it reads that as "use a library named 'm'" and then expands 'm' by 
> wrapping 'lib' and '.a' around it to make 'libm.a' (which it finds in 
> /usr/lib)."
> 
> Thanks everyone!
> 

Archive libraries in Linux are usually used to store .o's for the
purpose of statically linking a library into an executable.  Ideally,
only the .o's needed are statically bound in vs. the whole library.

Most programs don't use this style of binding to libraries anymore
and now prefer dynamically linking to shared objects (mistakenly
also called shared libraries).  The advantage is that the same
function could be used across multiple programs loaded in memory.
Binding can be done at program load time or dynamically by the
program itself (can do symbol lookups, calls, etc).

So .a's are usually not preferred unless you are wanting to build
a program that will run on a platform without the need of the library
being present (which can be a very useful thing when necessary).
Back before Motif was open... people would statically bind their
motif programs (e.g. the popular Mosaic web browser).




More information about the Discuss mailing list