[request] add --rpath for zlib and bzip2

Norihiko Murase skeleten at shillest.net
Sat Jan 15 19:56:46 CET 2005

I tried building GnuPG-1.2.6 under the following environment:
    CPU: i386 family
    OS: FreeBSD 4.8-RELEASE
    Compiler: gcc-2.95.4 (/usr/bin/gcc)
However, the built binaries (gpg, gpgv, ...) load the shared
libraries INCORRECTLY even if I add --enable-rpath option to
the configure script.
% ldd gnupg-1.2.6/g10/{gpg,gpgv}
	libz.so => /usr/lib/libz.so (0x280f3000)
	libbz2.so.1 => /usr/lib/libbz2.so.1 (0x28100000)
	libc.so.4 => /usr/lib/libc.so.4 (0x28110000)
	libz.so => /usr/lib/libz.so (0x280a2000)
	libbz2.so.1 => /usr/lib/libbz2.so.1 (0x280af000)
	libc.so.4 => /usr/lib/libc.so.4 (0x280bf000)
They should have loaded /usr/local/lib/lib{z,bz2}.so, NOT
that in /usr/lib.

I did build GnuPG-1.2.6 in the following method:
    [01]% bzip2 -cd gnupg-1.2.6.tar.bz2 | gtar xf -
    [02]% cd gnupg-1.2.6
    [03]% patch -p1 < ../patch_1
        The patch 'patch_1' is described at
    [04]% env MAKE=gmake ./configure               \
            --prefix=/usr/local/GnuPG              \
            .....                                  \
            --disable-nls                          \
            --enable-rpath --without-included-zlib \
            --with-zlib=/usr/local --with-bzip2=/usr/local
    [05]% gmake

The binaries (gpg, gpgv, ...) built in this method should
have loaded
However, the following libraries are loaded:
as the above result of ldd command tells.

I consider that the solution for this problem is to add the
--rpath option when you build binaries with the
--enable-rpath option specified.
    -L/usr/local/lib -Wl,--rpath -Wl,/usr/local/lib
    -L/usr/local/lib -Wl,--rpath -Wl,/usr/local/lib
    ... -lz -lbz2

It is also a fact that we can avoid this by setting LDFLAGS
environment variable "-R/usr/local/lib:/usr/local/lib" when
we execute the configure script.
  % env MAKE=gmake LDFLAGS="-R/usr/local/lib:/usr/local/lib" \
      ./configure .....

Norihiko Murase <skeleten at shillest.net>

More information about the Gnupg-devel mailing list