[freetds] ct-lib unit tests link statically
Johnny C. Lam
jlam at pkgsrc.org
Wed Jul 9 11:04:11 EDT 2008
James K. Lowden wrote:
> ZIGLIO, Frediano, VF-IT wrote:
>> For me it works even without -static flag, libtool use -rpath
>> option to specify path. In a previous environment I remember that
>> autoconf/automake/libtool/whatever produce an executable in .libs
>> directory and a script in unittests directory to override directory...
>> are you sure that it does not work so for you ??
>
> Yes, I'm sure. You're right, too, though.
>
> When I configure, I set LDPATH:
>
> LD_search='-L/usr/local/lib -L/usr/pkg/lib'
> LD_rpath='-Wl,--rpath -Wl,/usr/local/lib:/usr/pkg/lib'
> export LDFLAGS="${LD_search} ${LD_rpath}"
>
> And that rpath precedes the "local" one in the unit test binaries.
>
> $ ldd datafmt
> datafmt:
> -lpthread.0 => /usr/lib/libpthread.so.0
> -lct.4 => /usr/local/lib/libct.so.4
> -lc.12 => /usr/lib/libc.so.12
>
> $ readelf -d datafmt | grep -i rpath
> 0x0000000f (RPATH) Library rpath:
> [/usr/local/lib:/usr/pkg/lib:/usr/users/home/jklowden/freetds/build/src/c
> tlib/.libs]
>
> It's normal on a NetBSD system to embed the RPATH in every executable, and
> not to rely on LD_LIBRARY_PATH. LDFLAGS is the only way I know to do
> that.
>
> If we find a way to cause libtool's RPATH to precede the values in
> LDFLAGS, we could go back to dynamically linked unit tests.
Freddy's recollection is correct. Libtool should be generating a shell
script that properly sets LD_LIBRARY_PATH to reference the uninstalled
shared libraries in .libs before executing the built test binaries (also
in .libs). Setting LD_LIBRARY_PATH will override any embedded rpath
settings in the binaries (on NetBSD, "man ld.elf_so" for more
information). If it doesn't, then that usually points to deviating from
the "correct" way to use libtool in the Makefiles.
How are you verifying that the wrong shared libraries are being used?
Cheers,
-- Johnny C. Lam
More information about the FreeTDS
mailing list