Ubuntu temporary library search path

I have several versions of the same library to which my program is dynamically linked. Sometimes I would like to change the version used.

I read that newer versions of Ubuntu no longer support LD_LIBRARY_PATHfor security reasons. I could add the path to /etc/ld.so.confand run ldconfig, but I will not always have root privileges on the system.

Does anyone know how to make changes to the library search path that a simple user can do? Suppose this happens often enough that updating configuration files is the last.

Edit: this is how I test what I expect to see and so on: I run lddin the program and see libfoo.so => /some/path/to/lib/libfoo.so. I add /path/to/different/version/lib(which contains a file called libfoo.so) to LD_LIBRARY_PATHand rerun ldd. The path for libfoo.so is the same as before when I expect to see libfoo.so => /path/to/different/version/lib/libfoo.so.

Thank,

Andrew

+3
source share
1 answer

You can use patchelf to change RPATH(library search path) any executable. This is a cool utility and does not require special privileges to run. To install the program for the first search /opt/my-libs/lib, then /foo/libsimply do the following:

% patchelf --set-rpath /opt/my-libs/lib:/foo/lib program
+7
source

Source: https://habr.com/ru/post/1784428/


All Articles