在编译时将运行时共享库搜索路径添加到可执行文件|铿锵| Ubuntu
问题描述:
我正在编译的可执行文件需要在运行时将rpath
指向库文件。目前,我在编译具有可执行文件,在编译时将运行时共享库搜索路径添加到可执行文件|铿锵| Ubuntu
clang -O3 -mllvm -polly -mllvm -polly-target=gpu vector_add.c -lGPURuntime -ldl
,然后使用下列任一方法来提供rpath
,
- 它添加到
LD_LIBRARY_PATH
- 使用
patchelf --set-rpath $RPATH a.out
我需要一种方法来指示clang ....
命令本身中的rpath
。
我在Ubuntu 14.04 x86_64的运行clang5.0.0 - svn的(7cf8dd5ce168bed45b57e019149e33300c56f94b),并与ld.gold LLVM - svn的(85f508cd9dba8a982471d98c4f649fb0d63f3451)。
谢谢!
答
使用clang ... -Wl,-rpath,/path/to/run-time/library's/dir/
。这是一个gcc
风格选项,也可以在clang中使用。