How to add shared libraries to Linux's system library path
Sometimes in Linux when you install a new software package the instructions tell you to add a directory of shared libraries to your $LD_LIBRARY_PATH environment variable in your .bashrc.
You may have noticed that if you then create a shortcut icon on your desktop to this application it won't start because it can't find the libraries.
A typical solution is to write a wrapper shell script to set the LD_LIBRARY_PATH and then call that application.
Well, I've discovered how to add them to your system's library path allowing all environments to access them. Note: There are differences between Debian and Ubuntu (the two flavours of Linux that I'm familiar with).
Ubuntu
Create a new file in /etc/ld.so.conf.d/ called
Edit the file and add a line per directory of shared libraries (*.so files), it will look something like:
/usr/lib/APPLICATION/libReload the list of system-wide library paths:
sudo ldconfigDebian
Edit
/etc/ld.so.confAdd a line per directory of shared libraries (*.so files) to the bottom of the file, it will look something like:
/usr/X11R6/libReload the list of system-wide library paths:
/usr/lib/APPLICATION/lib
ldconfigIf you run your new application it should now work fine without you having to set any LD_LIBRARY_PATH environment variables.
If you still have problems you can obtain a list of the libraries that are on the system path by re-running the
ldconfig command in verbose mode:ldconfig -v
Technorati Tags: LD_LIBRARY_PATH, Ubuntu, Debian, Linux, Andrew Beacock



Buy Stuff From Amazon
3 Comments:
Hmmm, seems cool.
Joe joestain13@yahoo.com
Hi Andrew,
And now the other way around:
I want to run an application but without a specif library. The application runs fine when I rename/remove the library. But removing the library completely is to drastic for me.
Can I use ldconfig, ld.conf, etc. to do this?
If so, how?
Cheers,
Kasper
Kasper,
I'm sorry to say that I'm not sure how to solve your issue! You can exclude whole directories from the LD_LIBRARY_PATH but no don't know of a way to exclude a particular one.
I think the rename option is probably the best so that you could always resurrect it if another application required it.
If you find a good solution please let me know!
Post a Comment