为基于libtool的项目转义$ ORIGIN

问题描述 投票:1回答:1

对于不使用libtool的项目,我已成功设置RUNPATHLDFLAGS="-Wl,-rpath='\$$ORIGIN/../lib64',--enable-new-dtags"。但是,对于基于libtool的项目,我会得到RIGIN/../lib。是否可以使用单个export与libtool兼容/不带libtool?还是我必须检测是否正在使用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

linux gcc linker libtool
1个回答
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>
© www.soinside.com 2019 - 2024. All rights reserved.