LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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
 
LinkBack Search this Thread
Old 06-27-2008, 05:31 AM   #1
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Rep: Reputation: 30
Does LD_LIBRARY_PATH variable loads all shared libraries in the directory to ram


hi
Assume some 10 shared libraries(*.so files) are present in /usr/local/lib directory.

if i export the path like this
Code:
[babu@localhost ~]$ export LD_LIBRARY_PATH=/usr/local/lib:LD_LIBRARY_PATH
does all the 10 shared libraries(assumption) in the directory /usr/local/lib will be loaded to ram.
 
Old 06-27-2008, 06:14 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,534
Blog Entries: 51

Rep: Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604
No LD_LIBRARY_PATH does not load libraries into RAM, like any form of PATH it just points to a location on the system. Maybe check the "readahead" service.
 
Old 06-27-2008, 06:19 AM   #3
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 2,866

Rep: Reputation: 698Reputation: 698Reputation: 698Reputation: 698Reputation: 698Reputation: 698
No, they will not be loaded, they will be searched at load time.

When you add (you're adding an additional path to the environment variable LD_LIBRARY_PATH), do it like this:
Code:
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
This appends /usr/local/lib to the existing LD_LIBRARY_PATH; the way you've shown it you have replaced LD_LIBRARY_PATH with /usr/local/lib -- the $ are important!

Last edited by tronayne; 06-27-2008 at 06:21 AM.
 
Old 06-27-2008, 07:00 AM   #4
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,393
Blog Entries: 1

Rep: Reputation: 63
To load libs in cache you need to list the path (in this case /usr/local/lib) in /etc/ld.so.conf.
The cache is what you call "load in ram". In fact it not just pre-loads the libs in memory buffer but it builds a table with entries for all symbols on the so objects, discard duplicates and invalid entries.

Almost all general purpose distros already have /usr/local/lib listed in /etc/ld.so.conf. Check yours first.

After changing /etc/ld.so.conf you need to update the cache with the command "ldconfig".
To get a list of libs on the cache, use "ldconfig -p".

cheers,

Last edited by marozsas; 06-27-2008 at 07:06 AM.
 
Old 06-27-2008, 08:09 AM   #5
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
thanks for u r replys

the ldconfig -p says 1243 libs found in cache `/etc/ld.so.cache'(then it lists all the files) .Does this means all the 1243 files will be present in ram all the time.

in this link http://www.network-theory.co.uk/docs...cintro_25.html
the doc says
it(ie.shared libraries) must be loaded from disk before the executable will run

so after the executable is terminated does the shared library which is loaded(from the path present in LD_LIBRARY_PATH) will also be unloaded, right? or ,if another application wants the same shared library what does happen.

Quote:
the $ are important
thanks tronayne.

Last edited by babu198649; 06-27-2008 at 08:16 AM.
 
Old 06-27-2008, 08:24 AM   #6
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,393
Blog Entries: 1

Rep: Reputation: 63
No. once on cache it remains there until the cache is rebuilded by another "ldconfig" command.
You can easilly verify this by writing a small C program that use a simple C function on a shared library for your own. - ok, maybe not so easilly
Put your small lib in a distinct folder, like "/usr/local/testlib", put this path in /etc/ld.so.conf, re-run "ldconfig", verify it is in cache with ldconfig -p, run your test program, and when it finish, verify your lib still is in the cache.

This is a good exercice and you will learn a lot about linking and shared libs if you do it by yourself.

cheers,

Last edited by marozsas; 06-27-2008 at 08:25 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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error while loading shared libraries: libstdc++.so.5: cannot open shared object file: Franziss Linux - Newbie 10 06-28-2010 05:47 AM
Is there any variable like LD_LIBRARY_PATH for configuration files (etc and share) supersubu123 Linux - General 1 04-04-2008 01:49 PM
error while loading shared libraries: libgvc.so.3: cannot open shared object file coolrock Slackware 6 01-17-2007 05:10 PM
Static variable sharing in shared libraries ristiisa Programming 13 10-20-2006 09:08 AM
how to set LD_LIBRARY_PATH environment variable snakeo2 Linux - Newbie 3 05-25-2005 07:08 PM


All times are GMT -5. The time now is 02:00 PM.

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