1

I have an executable A which dynamically loads B.so, which in turn depends on C.so. C.so is not in the same folder as A and B.

I am trying to load B.so using QLibrary.load() but fail to do so as QLibrary.errorString() returns library C.so could not be loaded.

The QLibrary documentation says that LD_LIBRARY_PATH can be used, but I'd prefer not to do this. I'm using -Wl,-rpath,/path/to/C/ when linking B.so, but it doesn't help for the dynamic loading.

Any suggestions on how I can load B.so without resorting to LD_LIBRARY_PATH? Can I make it work with -rpath?

2 Answers2

0

The rpath should point to a directory not shared object file, try -Wl,-rpath,/path/to/ instead of -Wl,-rpath,/path/to/C.so

e.jahandar
  • 1,715
  • 12
  • 30
  • I made a mistake in the question; the rpath is pointing to the directory, and the .so file is given to the linker with the absolute path. – Markus Schlafli Jan 26 '17 at 06:49
0

The issue was that the rpath was actually not being modified.

I used ldd to check that the shared object files were actually being loaded, and they weren't. Then I used readelf -b and found that the RPATH was not correct.