LD_LIBRARY_PATH vs ld.so.conf

在LD_LIBRARY_PATH和 ld.so.conf上遇到点困难,搜索到有用的结果如下。

http://ubuntuforums.org/showthread.php?t=324660
/etc/ld.so.conf and run ldconfig
setting LD_LIBRARY_PATH is only useful if you have different versions of a library installed on a system and would prefer to use one over the other, or the executable is compiled to look for libraries in a specific location and you want to change it.

ld.so's cache wasn't up to date when you added /usr/local/lib/libxine.so (you have to run `ldconfig` after adding libraries, it rebuilds the cache; programs would load a lot slower if the lib paths were manually searched each time a program was opened) so it really couldn't locate the library, even though it was there.

上面的英文的意思是是不推荐用LD_LIBRARY_PATH ,LD_LIBRARY_PATH 可以作为不同版本的选择项。

Linux 共享库: LD_LIBRARY_PATH 与ld.so.conf
Linux 通用的做法是将非标准路经加入 /etc/ld.so.conf,然后运行 ldconfig 生成 /etc/ld.so.cache。 ld.so 加载共享库的时候,会从 ld.so.cache 查找。传 统上, Linux 的先辈 Unix 还有一个环境变量 - LD_LIBRARY_PATH 来处理非标准路经的共享库。ld.so 加载共享库的时候,也会查找这个变量所设置的路经。
有不少声音主张要避免使用 LD_LIBRARY_PATH 变量,尤其是作为全局变量。这些声音是:
* LD_LIBRARY_PATH is not the answer - http://prefetch.net/articles/linkers.badldlibrary.html
* Why LD_LIBRARY_PATH is bad - http://xahlee.org/UnixResource_dir/_/ldpath.html
* LD_LIBRARY_PATH - just say no - http://blogs.sun.com/rie/date/20040710

posted @ 2010-12-06 15:27  westfly  阅读(541)  评论(0编辑  收藏  举报