I run into this problem every once in a while.
I want to compile software into a non-standard location such as '/apps'. The software will compile without errors, but I am unable to execute the files due to some broken libraries.
I know this has something to do with linking the libraries, but I can't figure out how to prevent this during compilation.
For example: I'm trying to compile OpenSSL 0.9.7i onto a box here into the /apps/ssl directory.
Compile, make, make test, & make install all run fine without errors. I used a pretty straightforward set of buildflags. I'm installing to /apps/ssl
Code:
./Configure --prefix=/apps/ssl --openssldir=/apps/ssl no-threads zlib-dynamic solaris-sparcv9-gcc
However, when I try to run openssl I get an error:
Code:
$ /apps/ssl/bin/openssl
ld.so.1: /apps/ssl/bin/openssl: fatal: libssl.so.0.9.7: open failed: No such file or directory
I'm confused, because the libraries clearly ARE where I specified:
Code:
$ ls /apps/ssl/lib/libssl.so.0.9.7
/apps/ssl/lib/libssl.so.0.9.7
It's just that OpenSSL doesn't know about the location of these libraries:
Code:
$ ldd /apps/ssl/bin/openssl
libssl.so.0.9.7 => (file not found)
libcrypto.so.0.9.7 => (file not found)
libsocket.so.1 => /usr/lib/libsocket.so.1
libnsl.so.1 => /usr/lib/libnsl.so.1
libdl.so.1 => /usr/lib/libdl.so.1
libc.so.1 => /usr/lib/libc.so.1
libmp.so.2 => /usr/lib/libmp.so.2
/usr/platform/SUNW,Ultra-60/lib/libc_psr.so.1
I can workaround this error by setting the LD_LIBRARY PATH:
Code:
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/apps/ssl/lib:/usr/local/lib
$ ldd /apps/ssl/bin/openssl libssl.so.0.9.7 => /apps/ssl/lib/libssl.so.0.9.7
libcrypto.so.0.9.7 => /apps/ssl/lib/libcrypto.so.0.9.7
libsocket.so.1 => /usr/lib/libsocket.so.1
libnsl.so.1 => /usr/lib/libnsl.so.1
libdl.so.1 => /usr/lib/libdl.so.1
libc.so.1 => /usr/lib/libc.so.1
libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1
libmp.so.2 => /usr/lib/libmp.so.2
/usr/platform/SUNW,Ultra-60/lib/libc_psr.so.1
$ /apps/ssl/bin/openssl
OpenSSL> version
OpenSSL 0.9.7i 14 Oct 2005
OpenSSL>
But I'd prefer not to use some roundabout way to refer to these libraries. How can I get this to work without using LD_LIBRARY_PATH ?
I appreciate any help,
-= Stefan