LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-26-2006, 01:16 AM   #1
stefanlasiewski
Member
 
Registered: Aug 2003
Location: Berkeley, California, USA
Distribution: Red Hat Enterprise Linux, Debian & Ubuntu
Posts: 92

Rep: Reputation: 16
How to avoid LD_LIBRARY_PATH


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
 
Old 01-26-2006, 01:40 AM   #2
runlevel0
Member
 
Registered: Mar 2005
Location: Hilversum/Holland
Distribution: Debian GNU/Linux 5.0 (“Lenny”)
Posts: 290

Rep: Reputation: 31
Quite simple: Put the path into /etc/ld.so.conf and after this run ldconfig.
 
Old 01-26-2006, 01:40 AM   #3
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
That's because on solaris, the default library path is specified as /lib and /usr/lib. Look into the command 'crle' and that will solve your problem.

-twantrd
 
Old 01-26-2006, 07:04 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Using crle is risky, better to have the library path stored on the binary at build time by using the linker "-R" option.
 
Old 01-26-2006, 12:17 PM   #5
stefanlasiewski
Member
 
Registered: Aug 2003
Location: Berkeley, California, USA
Distribution: Red Hat Enterprise Linux, Debian & Ubuntu
Posts: 92

Original Poster
Rep: Reputation: 16
Question

Quote:
Originally Posted by jlliagre
Using crle is risky, better to have the library path stored on the binary at build time by using the linker "-R" option.
Excellent, I think that is exactly what I want to do-- specify the libraries at build time. I would prefer to not modify /etc/ld.conf if I can help it.

However, I forget how to do this when running "./Configure". I either set the LDFLAGS variable or use "./Configure --with-ldflags=-L=/dir/to/my/lib --other-flags", correct?

Last edited by stefanlasiewski; 01-26-2006 at 12:19 PM.
 
Old 02-01-2006, 08:18 PM   #6
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
-Wl,-rpath,$(DEFAULT_LIB_INSTALL_PATH)

for gcc compiles (building a program with Gcc and a simple "make"):
Code:
-Wl,-rpath,$(DEFAULT_LIB_INSTALL_PATH)
This is a good link:
http://www.tldp.org/HOWTO/Program-Li...libraries.html

Cheers .. PSM

Last edited by paulsm4; 02-01-2006 at 08:19 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ld_library_path fng_#1 Linux - Software 4 09-19-2004 11:33 PM
???? Ld_library_path ???? g452 Linux - Software 9 08-26-2004 03:00 PM
Ld_library_path barrys Mandriva 2 06-15-2004 12:19 PM
where is LD_LIBRARY_PATH Ninja_212 Slackware 4 10-07-2003 10:41 PM
Ld_library_path ? dahmad Linux - Newbie 5 02-21-2003 11:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration