LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-20-2008, 12:36 AM   #1
galapogos
Member
 
Registered: May 2008
Posts: 227

Rep: Reputation: 30
How to set LD_LIBRARY_PATH


Hi,

I'm having trouble running a program that I compiled that uses a dynamically linked library in /usr/local/lib. I've even compiled it with the -L/usr/local/lib flag, but when I ldd the executable it doesn't find the library.

Apparently the library directory isn't in LD_LIBRARY_PATH. I've read it's a bad idea to modify LD_LIBRARY_PATH, but how else can I specify the library location?

Thanks.

Last edited by galapogos; 11-20-2008 at 12:47 AM.
 
Old 11-20-2008, 12:42 AM   #2
mesiol
Member
 
Registered: Nov 2008
Location: Lower Saxony, Germany
Distribution: CentOS, RHEL, Solaris 10, AIX, HP-UX
Posts: 731

Rep: Reputation: 137Reputation: 137
Hi,

try

export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}

this will be the easiest way.

Best way IMHO is create a short shellscript which sets LD_LIBRARY_PATH than executes your program and after you close unset LD_LIBRARY_PATH.

For static solution you can put /usr/local/lib in /etc/ld.so.conf and run ldconfig.
Be careful this solution can break other library dependencies on your system.
 
Old 11-21-2008, 08:48 AM   #3
pwalden
Member
 
Registered: Jun 2003
Location: Washington
Distribution: Fedora FC19, Raspbian
Posts: 289

Rep: Reputation: 38
To permanently set it for all users.

$ su -
Password:
# cd /etc/ld.so.conf.d
# echo /usr/local/lib >local.conf
# exit

When you re-boot, the default LD_LIBRARY_PATH will include /usr/local/lib
 
Old 11-21-2008, 09:25 AM   #4
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,043

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
To wrap everything into a simple script is the easiest you can get. It's a non-invasive solution that won't cause trouble with the rest of your system.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Unale to permanently set LD_LIBRARY_PATH cheeta05r Fedora 7 08-30-2007 08:16 PM
Cannot set LD_LIBRARY_PATH in .cshrc (able to set other env variables) senthilpr_in Linux - Newbie 4 02-26-2007 12:46 PM
set LD_LIBRARY_PATH to what? itz2000 Linux - Newbie 3 11-15-2006 08:34 PM
how to set LD_LIBRARY_PATH environment variable snakeo2 Linux - Newbie 3 05-25-2005 07:08 PM
Permanently Set a Export Setting (LD_LIBRARY_PATH) nistelrooy Linux - General 1 11-25-2004 11:33 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration