Renaming and symlinking shared libraries

Alexander Leidinger Alexander at Leidinger.net
Sun Jul 9 14:01:55 UTC 2006


Quoting Alejandro Pulver <alepulver at FreeBSD.org> (Thu, 6 Jul 2006 16:15:34 -0300):

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On Tue, 04 Jul 2006 07:43:08 +0200
> Alexander Leidinger <Alexander at Leidinger.net> wrote:
> 
> 
> > >> Quoting Alejandro Pulver <alepulver at freebsd.org> (from Sat, 1 Jul 2006
> > >> 20:25:22 -0300):
> > >
> > > But then how do the databases/dbXX ports achieve the same result
> > > without it? I thought it should find it since there is a symlink
> > > in /usr/local/lib that points to it. I want that when I compile a
> > > program with -L/usr/local/lib/test -ltest it actually links to test-2
> > > for example. Please look at the dbXX ports to see what I mean.
> > 
> > If you link with "-ltest-2" or if you link lib/libtest.so ->  
> > lib/test2/libtest-2.so, it should work, else you have to use the new  
> > LDCONFIG infrastructure.
> > 
> 
> The problem is that there are many versions of libtest
> (lib/libtest-2.so, lib/libtest-3.so), and I want to select the library
> by adding a -L linker flag to the corresponding directory, without
> altering the program (each lib/test2, lib/test3, etc. has a symlink
> libtest.so which points to the corresponding one; I want the mapping to
> take effect at link time).
> 
> For example (note that  I didn't specify -ldb-4.2, just -ldb, and
> lib/db42 isn't in the linker path):
> % cc test.c -L/usr/local/lib/db42 -ldb
> % ldd a.out
> a.out:
>         libdb-4.2.so.2 => /usr/local/lib/libdb-4.2.so.2 (0x28077000)
>         libc.so.6 => /lib/libc.so.6 (0x2814a000)
> 
> When I try it after symlinking the lua4 library this happens:
> % cc test.c -L/usr/local/lib/lua4 -llua
> % ldd a.out
> a.out:
>         liblua.so => (not found)
>         libc.so.6 => /lib/libc.so.6 (0x2814a000)
> 
> I would like to achieve the same result as the first case.

Does the lua4 lib contain a SONAME entry?

% objdump -R -x /usr/lib/libsdp.so | grep SONAME
  SONAME      libsdp.so.2

Does our runtime linker follow runtime linker paths embedded into a lib
(gcc -L/path -R/path/foo -lbar) and does the libdb-4.2.so.2 contain a
runtime linker path entry (don't know how to check, maybe you have to
search the build logs for -R).

Bye,
Alexander.

-- 
You can disable tcsh's terminal beep if you `set nobeep'.
http://www.Leidinger.net  Alexander @ Leidinger.net: PGP ID = B0063FE7
http://www.FreeBSD.org     netchild @ FreeBSD.org  : PGP ID = 72077137


More information about the freebsd-ports mailing list