views:

23

answers:

1

Hi,

I have some shared/dynamic libraries installed in a sandbox directory. I'm building some applications which link agains the libraries. I'm running into what appears to be a difference between OSX and Linux in this regard and I'm not sure what the (best) solution is.

On OSX the location of library itself is recorded into the library, so that if your applications links against it, the executable knows where to look for the library at runtime. This works like expected with my sandbox, because the executable looks there instead of system wide install paths.

On Linux I can't get this to work. Apparently the library location is not present in the library itself. As I understand it you have to add the folders which contain libraries to /etc/ld.so.conf and regenerate the ld cache by running ldconfig.

This doesn't seem to do the trick for me because my libraries are located inside a users home directory. It looks like ldconfig doesn't like that, which makes sense actually.

How can I solve this? I don't want to move the libraries out of my sandbox.

A: 

On Linux, run your program with the environment variable LD_LIBRARY_PATH set to your sandbox dir.

(I remember having used a flag -R to include library paths in the binary, but either it has been removed from gcc or it was only available on BSD systems.)

larsmans
I somehow thought LD_LIBRARY_PATH was used by ldconfig. I didn't know you could just change it dynamically. It works like a charm. Thanks!
0x80