468,315 Members | 1,501 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,315 developers. It's quick & easy.

Meaning of .a extension

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.

Cheers
Giuseppe
Jun 27 '08 #1
2 1867
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. 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

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.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #2
On Jun 10, 2:24 pm, Victor Bazarov <v.Abaza...@comAcast.netwrote:
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:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Gyger | last post: by
reply views Thread by Boris Boutillier | last post: by
5 posts views Thread by Jeffry van de Vuurst | last post: by
4 posts views Thread by Wade | last post: by
24 posts views Thread by krishna | last post: by
3 posts views Thread by nimmiejoey | last post: by
87 posts views Thread by Robert Seacord | last post: by
6 posts views Thread by tommybiegs | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.