Renaming and symlinking shared libraries

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

Hash: SHA1

On Tue, 04 Jul 2006 07:43:08 +0200
Alexander Leidinger <Alexander at> wrote:

> >> Quoting Alejandro Pulver <alepulver at> (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/ ->  
> lib/test2/, it should work, else you have to use the new  
> LDCONFIG infrastructure.

The problem is that there are many versions of libtest
(lib/, lib/, 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 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: => /usr/local/lib/ (0x28077000) => /lib/ (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: => (not found) => /lib/ (0x2814a000)

I would like to achieve the same result as the first case.

Thanks and Best Regards,
Version: GnuPG v1.4.3 (FreeBSD)


More information about the freebsd-ports mailing list