【发布时间】:2020-05-17 18:06:21
【问题描述】:
如何防止libtool添加系统路径(即/usr/lib)到RUNPATH(rpath)?
在测试(检查)期间,MPFR libtool 在测试路径之前将系统路径添加到 rpath,即:
0x0000000000000001d (RUNPATH) 库运行路径:[/usr/lib:/LFSC/native/src/bmpfr/src/.libs]
因此,测试可以运行已安装的库(在第一个路径(系统)中)而不是测试库。这通常发生在重新安装软件时。也许这会影响安装升级。
这是因为现有依赖项的 .la 文件,例如libquadmath.la
删除 .la 文件可解决此问题。
但是根本没有理由将系统路径添加到硬编码的 RUNPATH 中。
有什么方法可以在不删除 .la 文件的情况下解决此问题? 当然我知道我可以更改生成的 libtool 脚本。
这是关于 ELF 文件中的硬编码运行路径,它对系统路径和 LD_LIBRARY_PATH 具有高优先级。您可以通过从源代码编译 MPFR 而无需安装来轻松理解这一点。在make check 之后在源文件夹根目录中运行:
readelf -a tests/tversion | grep PATH
您将看到没有系统路径的 RPATH。
然后将 libquadmath.la 添加到 gcc lib home 中,例如/usr/lib/gcc/x86_64-linux-gnu/6/ 删除测试并再次检查,然后再次检查tversion中的PATH
# libquadmath.la - a libtool library file
# Generated by libtool (GNU libtool 1.3134 2009-11-29) 2.2.7a
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='libquadmath.so.0'
# Names of this library.
library_names='libquadmath.so.0.0.0 libquadmath.so.0 libquadmath.so'
# The name of the static archive.
old_library='libquadmath.a'
# Linker flags that can not go in dependency_libs.
inherited_linker_flags=''
# Libraries that this one depends upon.
dependency_libs=' -lm'
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for libquadmath.
current=0
age=0
revision=0
# Is this an already installed library?
installed=yes
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/usr/lib/../lib'
【问题讨论】:
标签: testing shared-libraries autotools libtool