DTU计算中心的博客文章“LD_LIBRARY_PATH – or: How to get yourself into trouble!”指出:
这是真的吗? LD_LIBRARY_PATH
允许我们修改动态库的搜索路径,但是它真的抑制了确保二进制兼容性的soname查找吗?
(因为按照我的解释,Program Library HOWTO没有说任何这样的话。)
还是作者不知道保持一致的库版本控制方案的概念,因此假设所讨论的库未使用该方案?
最佳答案
我认为LD_LIBRARY仅应用于测试,而不应用于最终安装,因为它允许在使用标准库位置之前使用指定的库。但是,Linux文档项目对LD_LIBRARY_PATH进行了说明,并使其比我更清楚。
摄于2013年8月13日,摘自:http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
该文档内的链接较旧,在此处找到了预期的文章:http://xahlee.info/UnixResource_dir/_/ldpath.html
编辑
您可以覆盖在构建/安装过程中程序链接到的库,因为ld.so
将查找在运行时加载库的顺序。将加载在环境变量LD_LIBRARY_PATH内部指定位置找到的库,而不是指定默认路径(/lib
和/usr/lib
)的库。
来自man 8 ld.so
ld.so loads the shared libraries needed by a program, prepares the pro‐
gram to run, and then runs it. Unless explicitly specified via the
-static option to ld during compilation, all Linux programs are incom‐
plete and require further linking at run time.
The necessary shared libraries needed by the program are searched for
in the following order
o Using the environment variable LD_LIBRARY_PATH
(LD_AOUT_LIBRARY_PATH for a.out programs). Except if the exe‐
cutable is a setuid/setgid binary, in which case it is ignored.
o From the cache file /etc/ld.so.cache which contains a compiled
list of candidate libraries previously found in the augmented
library path. Libraries installed in hardware capabilities
directories (see below) are prefered to other libraries.
o In the default path /lib, and then /usr/lib.
关于linux - LD_LIBRARY_PATH是否真的引起不一致?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18206373/