LD_LIBRARY_PATH 到底是什么

1790阅读 0评论2016-03-17 Nivek.cao
分类:LINUX

它的工作原理大概是什么样的


/sbin/ldconfig -p | grep krb


http://www.ibm.com/developerworks/library/l-lpic1-102-3/

Loading specific libraries

If you're running an older application that needs a specific older version of a shared library, or if you're developing a new shared library or version of a shared library, you might want to override the default search paths used by the loader. This might also be needed by scripts that use product-specific shared libraries that might be installed in the /opt tree.

Just as you can set the PATH variable to specify a search path for executables, you can set the LD_LIBRARY_PATH variable to a colon-separated list of directories that should be searched for shared libraries before the system ones specified in ld.so.cache. For example, you might use a command like:

export LD_LIBRARY_PATH=/usr/lib/oldstuff:/opt/IBM/AgentController/lib

See Resources for additional details and links to other tutorials in this series.

This concludes our brief introduction to managing shared libraries on Linux.


also read this:
another explain:

前 面已经说明过了,库搜索路径的设置有两种方式:在环境变量 LD_LIBRARY_PATH 中设置以及在 /etc/ld.so.conf 文件中设置。其中,第二种设置方式需要 root 权限,以改变 /etc/ld.so.conf 文件并执行 /sbin/ldconfig 命令。而且,当系统重新启动后,所有的基于 GTK2 的程序在运行时都将使用新安装的 GTK+ 库。不幸的是,由于 GTK+ 版本的改变,这有时会给应用程序带来兼容性的问题,造成某些程序运行不正常。为了避免出现上面的这些情况,在 GTK+ 及其依赖库的安装过程中对于库的搜索路径的设置将采用第一种方式进行。这种设置方式不需要 root 权限,设置也简单:


$ export LD_LIBRARY_PATH=/opt/gtk/lib:$LD_LIBRARY_PATH


可以用下面的命令查看 LD_LIBRAY_PATH 的设置内容:


$ echo $LD_LIBRARY_PATH


至此,库的两种设置就完成了。

上一篇:各数据库处理并发时的机制---坑
下一篇:技巧: 使用truss、strace或ltrace诊断软件的"疑难杂症"