[PLUG] RPM/lib question

Terry Griffin griffint at pobox.com
Sat Mar 19 23:19:26 UTC 2005


On Saturday 19 March 2005 1:59 pm, Paul Heinlein wrote:
> On Sat, 19 Mar 2005, Elliott Mitchell wrote:
> > The *.so.* files should NEVER be links to the *.so files.
> > Conventional setup is <lib>.so -> <lib>.so.<major> ->
> > <lib>.so.<fullversion>, where <lib>.so.<fullversion> is the actual
> > library.
> >
> >> Or to simplify: Put the *.so files in the main package _unless_
> >> there are specific provisions that make that unnecessary. One such
> >> provision is non-symlink *.so.* files.
> >
> > This is not a provision, this is STANDARD practice! I haven't fully
> > explored the issue, but I believe using gcc as a front end to ld
> > will always unwind one level of symbolic links. I'm unsure whether
> > it checks for a filename of the form *.so.[0-9], but if you look at
> > what ldd tells you output always links to <lib>.so.[0-9].
>
> Binaries compiled with gcc and GNU ld never look for libfoo.so; they
> always look for libfoo.so.X. That's why the *.so files can be packaged
> with the -devel stuff. If you need the *.so symlinks, it's only at
> compile time, never at run time.
>
> -- Paul Heinlein <heinlein at madboa.com>

I don't know where you get that. If you say:

   gcc somefile.c -lsomelib

then ld is going to look for libsomelib.so. If it finds it then
that's the reference that will go in the binary even if libsomelib.so
is a symbolic link to libsomelib.so.X (which it often is). With -l it
will never look for libsomelib.so.X. If it can't find libsomelib.so
then it goes on to look for libsomelib.a.

If you really want the reference to libsomelib.so.X to end up in
the application's binary then you can't use the -l switch. You have
to say something like:

   gcc somefile.c /path/to/libsomelib.so.X

which I've no doubt is very common in make files or the ./configure
scripts that generate make files. But it's not something gcc or ld
do automatically.

Terry



More information about the PLUG mailing list