为什么分配export LD_LIBRARY_PATH=:

为什么分配export LD_LIBRARY_PATH=:

我知道

export LD_LIBRARY_PATH=xxxxx

将让内核在此路径中搜索目标库。

但为什么将其分配为':'

export LD_LIBRARY_PATH=:

有什么作用呢?如果 .so 在当前路径中则有效。

对了,我们分隔路径的时候,不应该用“;”吗? ?

前任:

export LD_LIBRARY_PATH=foo1;foo2

答案1

LD_LIBRARY_PATH 由动态链接器而不是内核使用。动态链接器的名称各不相同,但类似于 /lib64/ld-linux-x86-64.so.2。

它由 记录man ld.so。在我的系统上它说

LD_LIBRARY_PATH
          A list of directories in which to search for ELF libraries at execution
          time.  The items in the list are separated by either colons or
          semicolons, and there is no support for escaping either separator.

使用冒号的一个小优点是不需要引号,因为它;是 shell 的特殊字符。它还同意在 PATH 变量的值中使用冒号。

至于为什么LD_LIBRARY_PATH=:,我建议买一本更好的书或指南。

相关内容