Lunar Mushrooms
Lunar Mushrooms

Reputation: 8948

Why shared library path is hardcoded in execuatble?

Recently I got a test binary. When I checked it using objdump, I observed that it includes hard coded library path. Why it is needed to to hardcode the path like that? Shouldn't the path be taken from SHELL environment variables or -L parameter instead ?

objdump -p testprog

The output includes the hardcoded path to shared libraries:

....
  NEEDED      /home/test/lib/liba.so
  NEEDED      /home/test/lib/libb.so
  NEEDED      /home/test/lib/libc.so
....

Upvotes: 5

Views: 2713

Answers (1)

Alan Curry
Alan Curry

Reputation: 14721

This is probably because those three .so files had no SONAME on the host where your test program was built. Tell the person who built it to rebuild liba.so with -Wl,soname,liba.so and similar for the other two, then relink the main program.

Upvotes: 5

Related Questions