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

Re: Confusion over library names



"Michael and Ricia Banther" <ricia@primex.co.uk> wrote:
>I've just recently started using Debian Linux.  I've been trying out a
>"Hello, world" C++ program, and I've noticed what seems to be an odd naming
>disconnect with the files in /usr/lib.
>
>The ld program supports a -l<n> command line option.  This option, as I
>understand it, instructs ld to search the libraries /usr/lib/lib<n>.a and
>/usr/lib/lib<n>.so for unresolved globals.  However I see several libraries
>in /usr/lib with names such as libstdc++.so.272, that is, with something
>appended after the .a or .so.  Furthermore, although I see many symlinks for
>these files which effectively give a particular library several variations
>on a name, in some cases no symlink ending in .a or .so exists.

That's right. The conventions are described in chapter 12 of the Debian
Packaging Manual (install the packaging-manual package and it'll be in
/usr/share/doc/packaging-manual/packaging.html/ch-sharedlibs.html).
Sections 4.2 and 4.3 of the Debian Policy Manual (in the debian-policy
package) are also relevant.

Briefly, say you have a library called foo with version number 1.2.3,
and programs linked against any version 1.x.y of the library are
compatible: then you'd have /usr/lib/libfoo.so.1.2.3 and a symlink
/usr/lib/libfoo.so.1 pointing to it. That's all that's needed to run
programs linked against that library. See ld.so(8) and ldconfig(8).

In order to link fresh programs to the library, you need the symlink
/usr/lib/libfoo.so, as you've discovered. This is the shared version,
and /usr/lib/libfoo.a is the static version (not a symlink, a separate
file so that you can create executables with no external dependencies
[1]). However, since these are only needed for development, they are
only included in the -dev package. If you install all the relevant -dev
packages (you should have libstdc++2.10-dev or similar already?), then
your problems should go away.

[1] Sorry if I'm teaching grandmothers to suck eggs here; I'm not sure
    how much you already know. :)

>2. Should I create symlinks ending with .so (or .a) for any library with a
>name of the form lib<n>.so.blah (or lib<n>.a.blah)?

I'd leave them alone unless there's some kind of bug in the package. You
can use http://packages.debian.org/ to look for packages containing
files you can't find.

-- 
Colin Watson                                     [cjw44@flatline.org.uk]



Reply to: