Meaning of .a extension

Discussion in 'C++' started by Giuseppe.G., Jun 10, 2008.

  1. Giuseppe.G.

    Giuseppe.G. Guest

    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
     
    Giuseppe.G., Jun 10, 2008
    #1
    1. Advertising

  2. Giuseppe.G.

    James Kanze Guest

    On Jun 10, 2:24 pm, Victor Bazarov <> 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:
    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
     
    James Kanze, Jun 11, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand
    Replies:
    3
    Views:
    921
    Tim Daneliuk
    Nov 8, 2003
  2. Christian Seberino
    Replies:
    3
    Views:
    1,221
    Christian Seberino
    Feb 5, 2004
  3. Steve
    Replies:
    3
    Views:
    27,121
    Steve
    Aug 25, 2006
  4. Elhanan
    Replies:
    0
    Views:
    566
    Elhanan
    Jan 23, 2007
  5. Replies:
    4
    Views:
    821
Loading...

Share This Page