I have an executable which is dynamically linked to foo.so.0 and bar.so.0. The problem is that when I try to run the executable the loader cannot find the dynamically linked libraries. (The executable was linked to a static library which loaded the dynamic version so I dont control any of that directly). I found that I can edit LD_LIBRARY_PATH
to include the current directory and then it will find it. The problem is that when the program is run as root, for some reason it still cant find the library. Is the LD_LIBRARY_PATH
approach the wrong one? If it is acceptable then why does the program not find the library when run under sudo?
Antons answer: if it's your program, you can use ld's -rpath (gcc's -Wl,-rpath) to modify library search path for it. (Not that it doesn't feel like a hack too). Or you can install a script starting the program with LD_LIBRARY_PATH. Or you can put the libraries where they are searched by default.