为什么 -rpath 不起作用但“export LD_LIBRARY_PATH=...”起作用?

问题描述

我正在尝试编写我的 makefile 来编译依赖于 Ubuntu 中的 CUDA 的动态库。下面是我的命令:

g++ -std=gnu++11 -w -fopenmp  -fPIC -shared -o libdetect.so obj/detect.o -lpthread -lstdc++  -L  ../third_party -ldet_engine -Wl,-rpath=../third_party/lib/ubuntu-cuda10:../third_party -I../third_party/include -I. -I /usr/local/cuda/include

任何与 CUDA 相关的 .so 都位于“../third_party/lib/ubuntu-cuda10”中。但是在我执行“make”之后,“ldd libdetect.so”的内容中仍然没有包括cublas和cudart在内的CUDA组件:

...
        libcudart.so.10.0 => not found
        libcublas.so.10.0 => not found
        libcudart.so.10.0 => not found
...

但是如果我将“../third_party/lib/ubuntu-cuda10”附加到我的 LD_LIBRARY_PATH 中,一切都很好。

我了解到 "-rpath" 的优先级高于 LD_LIBRARY_PATH,但为什么 "-rpath" 不起作用但 LD_LIBRARY_PATH 呢?提前致谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)