I have an executable file called reg with the following shared library dependencies:
[terminal]$ ldd ./reg
linux-vdso.so.1 => (0x00007ffc40d90000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003be0c00000)
/usr/dep/packages/opt/intel/mkl/10.0.2.018/lib/em64t/libmkl_intel_lp64.so => not found
When executing the binary I get the following:
[terminal]$ ./reg
./reg: error while loading shared libraries: /usr/dep/packages/opt/intel/mkl/10.0.2.018/lib/em64t/libmkl_intel_lp64.so: cannot open shared object file: No such file or directory.
The thing is that I don't have the administrative rights to create the specified directory path and place the library there. Moreover, I don't have the source code so I can't re-compile it either but I do have libmkl_intel_lp64.so library stored somewhere else. I tried using LD_PRELOAD environment variable but it still needs that library in that specific location. Is there a solution how could I solve this problem?
Thank you!
Best Answer
I don't have the same binary you have but I made a little test and it seems that
patchelf
can work here. I have ahello
binary compiled with-Wl,-rpath=/home/ja/c/hello-puts/make/lib
andlibtest.so
as a dependency:I run
patchelf
with--make-needed-absolute
usingpatchelf
from https://github.com/dezgeg/patchelf/:I think that's what you have. I copied
hello
to other machine and:I first removed a needed
libtest.so
dependency:I tried to run
hello
, it started but due to lazy binding done by the interpreter only the first line of the expected output was shown:I added
libtest.so
again but without an absolute path:I copied
libtest.so
to$PWD
and was able to starthello
: