LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 5712|回复: 18

ld搜索库的路径是怎样确定的?

[复制链接]
发表于 2004-10-18 21:05:32 | 显示全部楼层 |阅读模式
在编译ld时,--with-lib-path可以指定库的路径,我想知道:如果没有指定,ld的默认搜索路径是什么?这个默认搜索路径是在configure中还是在源代码中确定的?

根据搜索到的资料,ld似乎使用了libtool来确定库的位置,是不是这样呢?
发表于 2004-10-19 05:44:15 | 显示全部楼层
/etc/ld.so.conf
 楼主| 发表于 2004-10-19 14:56:51 | 显示全部楼层
看起来不是这么简单的。我从别处找了点资料,也不知道对不对。看来只有以后分析源代码才能知道了。


在Linux下,大部分系统的library库被安装在/usr/lib目录下。只有一些
基本的共享库被安装在/lib目录下。例如:libc.so,libcurses.so,libm.so
,libtermcap.so(各个版本对应的文件会有些不同),在其他部分被mount上
之前,那些文件是启动Linux系统所必须的。连接器默认的搜索路径是
/lib,/usr/lib,/usr/local/lib。

环境变量LD_LIBRARY_PATH列出了查找共享库时除了默认路径之外的其他路径。
/etc/ld.so.conf文件则指出了程序ldconfig要搜索的目录。该程序将这些目录中所有的
共享库都存储到/etc/ld.so.cache中。假如共享库已经被从默认的目录中
移走,Linux ELF动态连接库将在/etc/ld.so.cache文件中找该共享库。


程序ldconfig将把/etc/ld.so.conf文件中列出的搜索目录中的所有的
共享库存储到/etc/ld.so.cache中。假如共享库已经被从默认的目录中
移走,Linux ELF动态连接库将在/etc/ld.so.cache文件中找该共享库。
发表于 2004-10-19 15:12:20 | 显示全部楼层
好文~
发表于 2004-10-19 18:21:55 | 显示全部楼层
对于普通用户无法修改/etc/ld.so.conf,又想用其他位置的库,就可以用LD_LIBRARY_PATH了
发表于 2004-10-22 23:11:09 | 显示全部楼层
#chroot $LFS /tools/bin/env -i \
HOME=/root TERM=$TERM PS1='\u:\w\$' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/tools/bin/bash --login +h
结果却错误,如下:
/tools/bin/env : error while loading shared libraries : libc.so.6:cannot open shared object file: No such file or directory
你说我的错误是不是共享库的搜索路径不对啊,要怎么样修正呢!!
发表于 2004-10-22 23:12:26 | 显示全部楼层
#chroot $LFS /tools/bin/env -i \
HOME=/root TERM=$TERM PS1='\u:\w\$' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/tools/bin/bash --login +h
结果却错误,如下:
/tools/bin/env : error while loading shared libraries : libc.so.6:cannot open shared object file: No such file or directory
你说我的错误是不是共享库的搜索路径不对啊,要怎么样修正呢!!
发表于 2004-10-22 23:13:02 | 显示全部楼层
#chroot $LFS /tools/bin/env -i \
HOME=/root TERM=$TERM PS1='\u:\w\$' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/tools/bin/bash --login +h
结果却错误,如下:
/tools/bin/env : error while loading shared libraries : libc.so.6:cannot open shared object file: No such file or directory
你说我的错误是不是共享库的搜索路径不对啊,要怎么样修正呢!!
发表于 2004-10-23 00:23:40 | 显示全部楼层
觉得是你的前边有东西装错了,尤其是glibc。
发表于 2004-10-23 00:28:17 | 显示全部楼层
觉得是你的前边有东西装错了,尤其是glibc。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表