-   Linux - Software (
-   -   How to set LD_LIBRARY_PATH (

galapogos 11-20-2008 12:36 AM


I'm having trouble running a program that I compiled that uses a dynamically linked library in /usr/local/lib. I've even compiled it with the -L/usr/local/lib flag, but when I ldd the executable it doesn't find the library.

Apparently the library directory isn't in LD_LIBRARY_PATH. I've read it's a bad idea to modify LD_LIBRARY_PATH, but how else can I specify the library location?


mesiol 11-20-2008 12:42 AM



export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}

this will be the easiest way.

Best way IMHO is create a short shellscript which sets LD_LIBRARY_PATH than executes your program and after you close unset LD_LIBRARY_PATH.

For static solution you can put /usr/local/lib in /etc/ and run ldconfig.
Be careful this solution can break other library dependencies on your system.

pwalden 11-21-2008 08:48 AM

To permanently set it for all users.

$ su -
# cd /etc/
# echo /usr/local/lib >local.conf
# exit

When you re-boot, the default LD_LIBRARY_PATH will include /usr/local/lib

i92guboj 11-21-2008 09:25 AM

To wrap everything into a simple script is the easiest you can get. It's a non-invasive solution that won't cause trouble with the rest of your system.

All times are GMT -5. The time now is 05:11 PM.