Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tlug: About libraries



--------------------------------------------------------
tlug note from "Andrew S. Howell" <andy@example.com>
--------------------------------------------------------
>>>>> "Chistophe" == Chistophe Gimenez <chris@example.com> writes:

    Chistophe> I would to know if somebody can help me with libraries
    Chistophe> files under Linux ?

The .a libraries are used when you statically link your
application. This means that all the code you need to run you
application is included in the application.  

The .so files are shared libraries. Applications linked against these
do not need to include the contents of the library in the program,
just the name of the library. This makes the program much
smaller. Since many programs can use the same .so, the system can make
better use of memory.

When an application starts, if it is linked against shared libraries,
it calls ld.so to load the shared libraries. To find you what shared
libraries a program uses, you can use ldd:

ldd /usr/bin/X11/fvwm
        libXpm.so.4 => /usr/X11R6.1/lib/libXpm.so.4
        libXext.so.6 => /usr/X11R6.1/lib/libXext.so.6
        libX11.so.6 => /usr/X11R6.1/lib/libX11.so.6
        libc.so.5 => /lib/libc.so.5.3.12

Separate from this, there are two main formats for executable files,
both programs and libraries, The old format is called a.out, which is
where the linux-aout comes from. The new format is called ELF.

    Chistophe> when I launch lddconfig, it search for a directories
    Chistophe> named linux-aout-...  and another named something like
    Chistophe> 'old.so'

The purpose of lddconfig is cache the location of the libraries, to
make finding them quicker. /etc/ld.so.conf as tells lddconfig where to
look for them in the first place.

    Chistophe> Can I delete theses directories ?

This depends. You need to make sure that your current applications to
not need any of the shared libraries in them. You can use ldd to find
out which libs a program is using. If you don't have anything that is
using a particular lib, you can delete it. I would recommend moving
"old" lib to some place that is not listed in /etc/ld.so.conf, until
you are sure that you don't need it anymore.

Although not used to often. If is possible for a program to load
shared libs after it is up and running. Perl 5, I believe, does this
to dynamicaly load extra Perl modules. In this case, ldd will NOT
report these libraries, hence one reason you don't want to just delete
libraries. You can delete old .a libs, as they are only used when you
compile a program.

If you want to find out the type binary, you can use "file"

file *
su:            setuid Linux/i386 demand-paged executable (ZMAGIC)
sync:          ELF 32-bit LSB executable i386 (386 and up) Version 1
tar:           Linux/i386 demand-paged executable (QMAGIC)

I've got a bunch of different executable types. If you have a recent gcc,
will generate ELF binaries by default. This is the preferred
format. Someday, I'll have everything moved to ELF, but its not a
priority.

    Chistophe> Another question :

    Chistophe> what are the .a lib files ? .so if the shared librarie
    Chistophe> but what about the a ?

See above.

Sorry this is a bit long.... I think I've got this all right, but
someone please correct me if I messed it up.

Andy

-----------------------------------------------------------------
a word from the sponsor will appear below
-----------------------------------------------------------------
The TLUG mailing list is proudly sponsored by TWICS - Japan's First
Public-Access Internet System.  Now offering 20,000 yen/year flat
rate Internet access with no time charges.  Full line of corporate
Internet and intranet products are available.   info@example.com
Tel: 03-3351-5977   Fax: 03-3353-6096


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links