Does LD_LIBRARY_PATH variable loads all shared libraries in the directory to ram
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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!
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".
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.