linux - Build OpenSSL with RPATH? -
i have ubuntu 14.04. came openssl 1.0.1f. want install openssl version (1.0.2) , want compile myself.
i configure follows:
ldflags='-wl,--export-dynamic -l/home/myhome/programs/openssl/i/lib -l/home/myhome/programs/zlib/i/lib' cppflags='-i/home/myhome/programs/openssl/i/include -i/home/myhome/programs/zlib/i/include' ./config --prefix=/home/myhome/programs/openssl/i \ zlib-dynamic shared --with-zlib-lib=/home/myhome/programs/zlib/i/lib \ --with-zlib-include=/home/myhome/programs/zlib/i/include make make install
after install, when check binary ldd openssl
, , result is:
... libssl.so.1.0.0 => /home/myhome/programs/openssl/i/lib/libssl.so.1.0.0 (0x00007f91138c0000) libcrypto.so.1.0.0 => /home/myhome/programs/openssl/i/lib/libcrypto.so.1.0.0 (0x00007f9113479000) ...
which looks fine. when check ldd libssl.so
, result is:
... libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007fac70930000) ...
it still uses system version of libcrypto. tried different ways build, result stays same.
my question how configure build in way, can hardcode binary , library dependencies of shared libraries without using ld_library_path
, or that.
my question how configure build in way, can hardcode binary , library dependencies of shared libraries without using
ld_library_path
, or that.
openssl supports rpath
's out of box bsd targets (but not others). configure:
# unlike other oses (like solaris, linux, tru64, irix) bsd run-time # linkers (tested openbsd, netbsd , freebsd) "demand" rpath set on # .so objects. apparently application rpath not global , # not apply .so linked other .so. problem manifests # when libssl.so fails load libcrypto.so. 1 can argue # should engrave makefile.shared rules or bsd-* config # lines above. meanwhile let's try cautious , pass -rpath # linker when --prefix not /usr. if ($target =~ /^bsd\-/) { $shared_ldflag.=" -wl,-rpath,\$(librpath)" if ($prefix !~ m|^/usr[/]*$|); }
the easiest way openssl 1.0.2 appears be add cflag
:
./config -wl,-rpath=/usr/local/ssl/lib
the next easiest way openssl 1.0.2 appears be add configure line , hard code rpath
. example, working on debian x86_64. opened file configure
in editor, copied linux-x86_64
, named linux-x86_64-rpath
, , made following change add -rpath
option:
"linux-x86_64-rpath", "gcc:-m64 -dl_endian -o3 -wall -wl,-rpath=/usr/local/ssl/lib:: -d_reentrant::-wl,-rpath=/usr/local/ssl/lib -ldl:sixty_four_bit_long rc4_chunk des_int des_unroll: ${x86_64_asm}:elf:dlfcn:linux-shared:-fpic:-m64:.so.\$(shlib_major).\$(shlib_minor):::64",
above, fields 2 , 6 changed. correspond $cflag
, $ldflag
in openssl's builds system.
then, configure new configuration:
$ ./configure linux-x86_64-rpath shared no-ssl2 no-ssl3 no-comp \ --openssldir=/usr/local/ssl enable-ec_nistp_64_gcc_128
finally, after make
, verify settings stuck:
$ readelf -d ./libssl.so | grep -i rpath 0x000000000000000f (rpath) library rpath: [/usr/local/ssl/lib] $ readelf -d ./libcrypto.so | grep -i rpath 0x000000000000000f (rpath) library rpath: [/usr/local/ssl/lib] $ readelf -d ./apps/openssl | grep -i rpath 0x000000000000000f (rpath) library rpath: [/usr/local/ssl/lib]
once perform make install
, ldd
produce expected results:
$ ldd /usr/local/ssl/lib/libssl.so linux-vdso.so.1 => (0x00007ffceff6c000) libcrypto.so.1.0.0 => /usr/local/ssl/lib/libcrypto.so.1.0.0 (0x00007ff5eff96000) ... $ ldd /usr/local/ssl/bin/openssl linux-vdso.so.1 => (0x00007ffc30d3a000) libssl.so.1.0.0 => /usr/local/ssl/lib/libssl.so.1.0.0 (0x00007f9e8372e000) libcrypto.so.1.0.0 => /usr/local/ssl/lib/libcrypto.so.1.0.0 (0x00007f9e832c0000) ...
openssl has compilation , installation on wiki. has been added wiki @ compilation , installation | using rpaths
Comments
Post a Comment