I'm trying to get my executable to load some shared libraries from its own directory, so I decided to add .
to the rpath.
But when I try to run it, it doesn't find the .so.
Here is the interested part of the result of readelf -d myexec :
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libtoload.so.1]
0x00000001 (NEEDED) Shared library: [libpthread.so.0]
0x00000001 (NEEDED) Shared library: [libm.so.6]
0x00000001 (NEEDED) Shared library: [libc.so.6]
0x0000000f (RPATH) Library rpath: [$ORIGIN/.:.]
My folder contains :
-rwxr-xr-x 1 root root 97148 Apr 3 12:10 libtoload.so.1
-rwxr-xr-x 1 root root 9873 Apr 3 10:10 myexec
The error :
/some/folder/ # ./myexec
./myexec: error while loading shared libraries: libtoload.so.1: cannot open shared object file: No such file or directory
Note : I don't have any access to the LD_LIBRARY_PATH env variable (in fact it doesn't even exist) and the other libraries are in the /lib folder and loaded fine (but I can't put libtoload.so.1) there. I am actually cross compiling the executable from another computer, and only have access to a few commands on the target system (no toolchain, mostly busybox commands).
EDIT: /lib/ld-linux.so.3 --library-path ./ ./myexec works
User contributions licensed under CC BY-SA 3.0