tags:

views:

42

answers:

2

I have a shared library with soname: libfoo.so

How do I link my binary to libfoo.so such that the shared library name in my binary's ELF section is: libfoo5.so?

I tried creating a symlink: libfoo5.so -> libfoo.so, and then linking my library as such:

g++ ... -o mybinary *.o -Lpath -lfoo5

However, when I print out the dynamic section in my ELF binary, it reads:

readelf -d mybinary

I still get:

Shared library: [libfoo.so]

+1  A: 

The file libfoo5.so is probably a symlink to actual libfoo.so or something of that sort. What does ldd say about your binary?

Nikolai N Fetissov
libfoo5.so is a symlink to libfoo.soldd report mybinary depends on libfoo.so
zer0stimulus
So, does that clear the confusion?
Nikolai N Fetissov
I thought the compile-time linker doesn't follow symlinks and will associate the binary with libfoo5
zer0stimulus
Recursing ... what's the `SONAME` from `readelf -d libfoo5.so`?
Nikolai N Fetissov
+1  A: 

You usually do it when building the shared library. There is a linker option called "soname" that sets it.

I don't know off-hand if you can edit it after the build, but if its possible it is probably included in the package called "elfutils". That package contains several programs designed to manipulate ELF object files.

Zan Lynx