LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 10-20-2005, 03:04 AM   #1
hongxing
Member
 
Registered: Oct 2005
Posts: 73

Rep: Reputation: 15
what's usage of LD_LIBRARY_PATH?


can anyone explain in detail?
 
Old 10-20-2005, 07:02 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
It is used as a shell variable so that ld (see "man ld") will know what directories to search for shared libraries.

To set it you type:
LD_LIBRARY_PATH=/1stpath/to/libraries:/2ndpath/to/libraries (:...)

Example for Oracle (truncated here) on one of my servers I have:
LD_LIBRARY_PATH=/opt/oracle/product/10.1.0/db_1/lib:/lib:/usr/lib:/opt/oracle/product/10.1.0/db_1/jdk/jre/lib/i386

The above would tell it to first search for a given library in /opt/oracle/product/10.1.0/db_1/lib. If not found there it would
then search in /lib. If not found there it would then search in /usr/lib and so on.

Of course you have to export it like any variable to make it available:

export LD_LIBRARY_PATH
 
Old 10-20-2005, 06:57 PM   #3
hongxing
Member
 
Registered: Oct 2005
Posts: 73

Original Poster
Rep: Reputation: 15
thanks

do you mean is it used to specify the lib path to link when programming?

when running my app, how to specify the lib path?

thanks!
 
Old 10-21-2005, 07:47 AM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
The same way. Some programs (Oracle again as an example) use the variable for runtime as well as linking.
 
Old 10-21-2005, 02:35 PM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,642
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
When Linux searches for a library file, it looks at various locations in a certain order. This information is spelled out by man ld.so and, for your convenience, is reproduced here:
Code:
The necessary shared libraries needed by the program are  searched  for
in the following order:

o Using  the  DT_RPATH  dynamic section attribute of the binary if
  present and DT_RUNPATH attribute does not exist.

o Using the environment variable LD_LIBRARY_PATH.  Except if  the
  executable  is  a  setuid/setgid  binary,  in  which  case it is
  ignored.

o Using the DT_RUNPATH dynamic section attribute of the binary  if
  present.

o From  the  cache file /etc/ld.so.cache which contains a compiled
  list of candidate libraries previously found  in  the  augmented
  library  path.  If, however, the binary was linked with -z node-
  flib linker option, libraries in the default library  paths  are
  skipped.  (Note: the ldconfig program builds this cache.)

o In  the default path /lib, and then /usr/lib.  If the binary was
  linked with -z nodeflib linker option, this step is skipped.

Last edited by sundialsvcs; 10-21-2005 at 02:37 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
getting realtime info on memory usage-cpu and harddrive usage steering Linux - Newbie 5 03-03-2005 08:43 PM
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
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 04:45 AM
Ld_library_path Dogface1SG Linux - Software 1 11-16-2003 01:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:21 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