0

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

Lectem
  • 503
  • 6
  • 19
  • 1
    *Everyone* has access to the environment variables, and if one doesn't exist it's easy to create one (e.g. `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/lib/path`). Or just temporary when running your program `LD_LIBRARY_PATH=. ./myexec`. – Some programmer dude Apr 03 '15 at 11:50
  • Sadly it doesn't work, /lib/ld-linux.so.3 --library-path ./ ./myexec works though – Lectem Apr 03 '15 at 12:18
  • Ok, so it does work when using LD_LIBRARY_PATH=. ./myexec but not when setting LD_LIBRARY_PATH=. and then calling ./myexec. I checked the value with echo $LD_LIBRARY_PATH and it gives me "." which should be fine... – Lectem Apr 03 '15 at 12:40

0 Answers0