1

I have a closed-source library that comes in a file named libfoo.so.1.2.3.4. objdump -p shows it doesn't have SONAME but does have RPATH=/usr/local/lib.

Is it a bad practice? Should I try to push the library authors to change the options?

How am I supposed to link my code against it? I don't want to change any system-wide configuration or pollute directories writable by only root.

I created a dummy a.c file with an empty main() and trying to link with gcc a.c -L. -lfoo. It fails. If I create libfoo.so -> libfoo.1.2.3.4.so symlink by hand and set export LD_LIBRARY_PATH=$(pwd) it works and ldd says libfoo.so => {correct path}.

So it kind of works, but is it the recommended way?

nponeccop
  • 13,527
  • 1
  • 44
  • 106

1 Answers1

0

Is it a bad practice?

Not by itself, no. However, it's likely that the library authors are clueless, especially if you followed their installation procedure, and ended up with libfoo.so.1.2.3.4, but no symlink.

Should I try to push the library authors to change the options?

Possibly. Not setting SONAME and setting RPATH aren't bad by themselves, but not providing a symlink certainly is.

set export LD_LIBRARY_PATH=$(pwd)

That is generally a bad idea. You should prefer to encode the correct RPATH into the binary (and only the binary) which uses the library. On Linux, you can achieve that with -Wl,--rpath=$(pwd).

Employed Russian
  • 199,314
  • 34
  • 295
  • 362