对于不使用libtool的项目,我已成功设置了RUNPATH
LDFLAGS="-Wl,-rpath='\$$ORIGIN/../lib64',--enable-new-dtags"
。但是,对于基于libtool的项目,我得到RIGIN/../lib
。是否可以使用与libtool兼容的单个export
?或者我是否必须检测是否正在使用libtool?
bash-4.3# readelf -d ../tmp/bin/grep
Dynamic section at offset 0x43028 contains 18 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libc.so]
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/../lib]
...
bash-4.3# readelf -d ../tmp/bin/awk
Dynamic section at offset 0x9b028 contains 18 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libc.so]
0x000000000000001d (RUNPATH) Library runpath: [RIGIN/../lib]
...
编辑:
更正,我正在使用-Wl,-rpath="'\$$ORIGIN'"/../lib,--enable-new-dtags
答案 0 :(得分:0)
当尝试为自动工具配置脚本设置LDFLAGS时,我遇到了同样的问题。像这样设置对我有用:
LDFLAGS="-Wl,-rpath,'\$\$ORIGIN/../lib' -Wl,-rpath,'\$\$ORIGIN/../usr/lib'"
在构建过程中,它转换为libtool参数,如下所示:
/bin/sh ../../libtool --tag=CC --mode=link gcc -Wall -I/usr/include/openssl ...<skip>... -lrt -Wl,-rpath,'$ORIGIN/../lib' -Wl,-rpath,'$ORIGIN/../usr/lib' -o libcrypto_backend.la libcrypto_backend_la-crypto_cipher_kernel.lo libcrypto_backend_la-crypto_storage.lo libcrypto_backend_la-pbkdf_check.lo libcrypto_backend_la-crc32.lo libcrypto_backend_la-crypto_openssl.lo
由于我不得不从另一个包装器makefile LDFLAGS变量中调用./configure脚本,因此看起来更加有趣:
LDFLAGS="$(OS_LDFLAGS) -Wl,-rpath,'\$$\$$ORIGIN/../lib' -Wl,-rpath,'\$$\$$ORIGIN/../usr/lib'" ./configure ...<skip>