LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   How to (temporarily) add a library search path? (http://www.linuxquestions.org/questions/programming-9/how-to-temporarily-add-a-library-search-path-564092/)

G00fy 06-24-2007 03:11 AM

How to (temporarily) add a library search path?
 
I try to execute a program. It gives me this "cannot open shared object file: No such file or directory" error...

I know I can add it to ld.so.conf and run ldconfig. But that's not what I want... For example on windows you can just copy the responsible "dll" to the executable directory and it works as well.

But how can I achieve the same in Linux? I tried already making a softlink with the same name to the executable directory, but that didn't work...


Anyone knows :)?


Greetz,
Steven

b0uncer 06-24-2007 06:16 AM

Maybe create the softlink into a directory that is always checked for libs, like /usr/lib for example? Or define the library variable manually with export.. (note: I don't remember what it's exactly called, check using console).

G00fy 06-24-2007 06:21 AM

Sorry :) I found it while googling.

For someones reference:

LD_LIBRARY_PATH=/your/dir <executable>

in my case it was:
me@mydesktop:/var/tmp/my_program$ LD_LIBRARY_PATH=/var/tmp/my_libs ./my_program

ta0kira 07-03-2007 08:59 AM

If you are the developer of the program, use -rpath-link path and -rpath path when linking. -rpath-link provides a search path for link resolution to make sure you have a good link, but does nothing for run-time. When you use -rpath, that adds a path to the binary so that at run-time ld will search that path for dependent libraries.
ta0kira

ta0kira 07-03-2007 09:06 AM

Example: program needs library libprogram.so which is located at ../lib from the build directory, and after installation it will be located in the same path as program. You would use -rpath-link ../lib -rpath . when linking program to libprogram.so.
ta0kira


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