Thread: Libraries

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    30
    Rep Power
    2

    Libraries


    I was studying about shared and static libraries today and was looking into /usr/lib folder. I found libc.a and libc.so in /usr/lib folder.

    Can anyone explain which library is exactly used and why there is both ?
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    libc.a is the static C library and libc.so is the shared version of the same library.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    30
    Rep Power
    2
    Originally Posted by Scorpions4ever
    libc.a is the static C library and libc.so is the shared version of the same library.
    Yes. But which library will be used , whether static or shared ?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    San Francisco Bay
    Posts
    1,939
    Rep Power
    1313
    Normally the shared ones (when they exist), but you can opt to link statically. The exact syntax will depend on the linker, but on a GNU system:
    Code:
    $ gcc myprog.c    -o myprog               # link against shared objects
    $ gcc myprog.c    -o myprog    -static    # link statically

IMN logo majestic logo threadwatch logo seochat tools logo