Renaming and symlinking shared libraries

Alejandro Pulver alepulver at FreeBSD.org
Thu Jul 6 19:15:35 UTC 2006


-----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.

Thanks and Best Regards,
Ale
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (FreeBSD)

iD8DBQFErWFqiV05EpRcP2ERAkXvAKCXD9ondaFuZKtUBQ0JErFaTFElVQCffUPb
2I6CCcmKKNZ9caE7ujk0yLc=
=Y8Ao
-----END PGP SIGNATURE-----


More information about the freebsd-ports mailing list