【问题标题】:Adding run-time shared library search-path to executable at compile-time | clang | Ubuntu在编译时将运行时共享库​​搜索路径添加到可执行文件|铿锵声| Ubuntu
【发布时间】:2017-07-25 15:06:41
【问题描述】:

我正在编译的可执行文件在运行时需要 rpath 到库文件。目前,我正在编译可执行文件,

clang -O3 -mllvm -polly -mllvm -polly-target=gpu vector_add.c -lGPURuntime -ldl

然后使用以下任一方法提供rpath

  1. 将其添加到LD_LIBRARY_PATH
  2. 使用patchelf --set-rpath $RPATH a.out

我需要一种方法来在clang .... 命令本身中指示rpath

我在 Ubuntu 14.04 x86_64 中使用 ld.gold 运行 clang5.0.0-svn(7cf8dd5ce168bed45b57e019149e33300c56f94b) 和 llvm-svn(85f508cd9dba8a982471d98c4f649fb0d63f3451)。>

谢谢!

【问题讨论】:

    标签: clang ubuntu-14.04 x86-64 gold-linker


    【解决方案1】:

    使用clang ... -Wl,-rpath,/path/to/run-time/library's/dir/。这是一个 gcc 样式选项,也适用于 clang。

    【讨论】:

      猜你喜欢
      • 2012-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-10
      • 2011-11-29
      • 2017-06-18
      • 2015-01-07
      • 1970-01-01
      相关资源
      最近更新 更多