0

I have set the binary's rpath to the following: /usr/$LIB/test:$ORIGIN/lib/

The libraries are located at /usr/lib64/test, but when I run my binary it says it can't find those libraries.

I have checked the rpath with readelf -d.

The question is simple - why?


Upgrade #1

OS: Ubuntu 12.04.3 LTS
ld version: 2.15

Community
  • 1
  • 1
abyss.7
  • 13,882
  • 11
  • 56
  • 100
  • I don't believe you can use shell variable expansion in rpath. Use real paths. – keltar Apr 01 '14 at 11:09
  • @keltar read `man 8 ld.so` – abyss.7 Apr 01 '14 at 11:50
  • Ouch, haven't knew that, tried with ordinary variables. ORIGIN works for me, try `ldd ./your_program` and add output to question if you'll find anything unusual. – keltar Apr 01 '14 at 11:53
  • @keltar the `ldd` just shows `not found` for my libs. And the question is about the `$LIB` part. – abyss.7 Apr 01 '14 at 11:58
  • What's your version of ld.so? `ls -l /lib64/ld-linux-x86_64.so.2` - it's the number e.g. `ld-2.17.so`, if it's smaller than 2.3.2, then it implies you don't have `$LIB` variable expansion available as it was introduced in that version. `$ORIGIN` and `$PLATFORM` were introduced in 2.1 – Anya Shenanigans Apr 01 '14 at 12:02
  • There are also some rules for setuid executables (only bareword `$ORIGIN` is permitted/interpreted) – Anya Shenanigans Apr 01 '14 at 12:07
  • @Petesh `/lib64/ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.15.so` – abyss.7 Apr 01 '14 at 12:14
  • What distro? On my debian `$LIB` gets expanded to `lib/x86_64-linux-gnu` (so, `/usr/$LIB` becomes `/usr/lib/x86_64-linux-gnu`) – keltar Apr 01 '14 at 12:24
  • @keltar How do you know what is an expansion? Also, I have updated question. – abyss.7 Apr 01 '14 at 12:47
  • @abyss.7 I know no way to query that, sorry. All I know is that in amd64 debian system libraries are placed in `/usr/lib/`, so I've tried that and it worked. At home I have gentoo, which uses `/usr/lib64` - it works quite well in *this* directory too. The thing is, $LIB is different between distros. As for ubuntu, I don't have it at the moment, so can't check that. – keltar Apr 01 '14 at 12:51
  • This seems to be an explanation as to the why, but doesn't really help in determining the what: http://stackoverflow.com/questions/12312053/why-does-linux-multiarch-use-x86-64-linux-gnu-instead-of-lib64 – Anya Shenanigans Apr 01 '14 at 13:37

0 Answers0