Re: Meaning of .a extension
On Jun 10, 2:24 pm, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
Giuseppe.G. wrote:
Hi what are .a files used for? Are they a kind of archive to
hold libraries? I've installed a toolkit that puts some .h
files into /usr/ local/src and a .a file into
/usr/local/lib. However, I don't know how to instruct the
compiler to use the contents of the .a file, if it's really
needed and for what.
.a files in Unix are "archives" of object modules.
Or of anything else. They're files created by the "ar" utility,
and can be used to archive anything. (In the old days, you had
to run ranlib on the output of ar before the linker could use
it. ranlib created an additional index file, and then inserted
it at the start. I think this has pretty much disappeared.)
I've often wondered, in fact, why compilers didn't treat a
request for the library as part of the include path, so that you
could add your headers to the library as well, and thus package
the library as a single file.
They are basically
an equivalent of .lib files on Windows (if you're more familiar with
that environment). A .a file is used by the linker; if the name of the
file you need to add is libXXX.a, you add it to the command line like so:
cc ... -lXXX
That's one way, and it also causes the compiler to look for the
library in a number of specified places (much along the lines of
how it looks for a header file). You can also specify the
pathname directly.
where the letter after the minus is a small L. But all this
is not really a feature of the language, it's a feature of the
OS and your compiler. Please direct your further inquiries to
the newsgroup dedicated to your platform.
I agree that it's platform specific, but I'm not sure I'd call
it a feature:-).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34