Dynamic linking with rpath not working under Ubuntu 17.10

前端 未结 1 988
傲寒
傲寒 2020-12-06 13:11

I build an R package which uses Rcpp and links to a third-party shared object (libbarraopt.so) (which also links to other shared objects such as liboptsrv

相关标签:
1条回答
  • 2020-12-06 13:26

    It seems that -Wl,-rpath is not effective here.

    What likely happened is that your updated linker emits DT_RUNPATH dynamic tag, where the old linker emitted DT_RPATH. (It's also possible that your old linker was GNU-ld, and the new one is Gold.)

    The DT_RUNPATH is preferred as more correct, and affects search path of the binary itself, but not of any of the dependent libraries.

    The DT_RPATH has global effect, similar to adding the directory to LD_LIBRARY_PATH environment variable.

    You can verify this with: readelf -d a.out | grep 'R.*PATH'.

    If you do see the RPATH vs. RUNPATH difference, and in fact are using Gold, you can force the "old" behavior with -Wl,--disable-new-dtags (GNU ld also had --disable-new-dtags added to it recently, so it should work for either linker).

    0 讨论(0)
提交回复
热议问题