LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-19-2010, 08:28 AM   #1
deostroll
Member
 
Registered: Aug 2007
Location: Bangalore
Distribution: fedora
Posts: 112

Rep: Reputation: 15
export command


Hi, can't understand what the command does:
Code:
export LD_LIBRARY_PATH=/opt/lib:$LD_LIBRARY_PATH
What are we communicating here?
 
Old 02-19-2010, 08:38 AM   #2
JimBrewster
Member
 
Registered: Feb 2010
Location: usa:/dev/random
Distribution: Slackware, Salix
Posts: 237

Rep: Reputation: 59
Okay, I'll work from the inside out.

$LD_LIBRARY_PATH is an environmental variable that tells programs where to look for shared program code. If you run 'echo $LD_LIBRARY_PATH' it will return a list of directories separated by colons.

'LD_LIBRARY_PATH=/opt/lib:$LD_LIBRARY_PATH' adds the directory '/opt/lib' to the list.

'export' makes the variable assignment available outside the current shell.

Hope this helps...
 
Old 02-19-2010, 09:01 AM   #3
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
Hi deostroll,

Code:
export LD_LIBRARY_PATH=/opt/lib:$LD_LIBRARY_PATH
/etc/ld.so.cache is the cache containing ordered list of libraries found in /etc/ld.so.conf. Our applications search in this cache for any library.

Before searching in the above cache you can make the application to search in LD_LIBRARY_PATH to figure out the library.

This is exactly similar to your PATH environmental variable, wherein executables are searched. Here you are searching for a shared object i.e., .so file.

Here /opt/lib is being appended to your old LD_LIBRARY_PATH. If the above way of appending is confusing you can follow this way

Code:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lib
Both are one and the same..

Last edited by vinaytp; 02-19-2010 at 09:02 AM.
 
Old 02-19-2010, 09:59 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156
.. export .. continued story ..

export LD_LIBRARY_PATH=/opt/lib
.. will add a path.

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lib
.. will exclude other paths (/usr/lib:/lib etc.)
on most Linux.

Both commands are temporary : The path will reset to default :
/usr/lib:/lib:/usr/local/lib etc. when you exit the terminal.
.....
 
Old 02-20-2010, 01:55 AM   #5
deostroll
Member
 
Registered: Aug 2007
Location: Bangalore
Distribution: fedora
Posts: 112

Original Poster
Rep: Reputation: 15
we need only execute the above command if we are trying to load libraries dynamically from a c program, right? [Think the function is dlsym()??]
 
Old 02-20-2010, 07:55 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156
The "export LD_LIBRARY_PATH..." command is used when
you have libraries located in a non system path.

1) At compile time, using gcc, g++, etc.

2) By running an executable.

Quote:
We need only execute the above command if we are trying to
load libraries dynamically from a c program, right?
By my understanding, you are not doing anything with a c program.
It must be compiled before it can work. And then it is not really
c anymore.
.....

Last edited by knudfl; 02-20-2010 at 07:57 AM.
 
  


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
export path command davidleroux1 Mandriva 8 01-19-2006 09:22 PM
export command rohr Mandriva 1 04-11-2005 06:24 AM
set/export command? blackzone Linux - Newbie 1 03-05-2005 08:11 PM
BASH export command galalleni Slackware 4 09-08-2003 01:44 AM
Export Command choawk Linux - General 1 06-06-2003 02:26 AM


All times are GMT -5. The time now is 12:28 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration