查看和刷新动态库:ldconfig与 /etc/ld.so.conf

本文详细介绍了ldconfig命令及/etc/ld.so.conf配置文件的使用方法,包括如何通过修改配置文件添加自定义库路径并刷新缓存,从而提高库文件加载速度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ldconfig与 /etc/ld.so.conf
2010年10月11日 星期一 上午 11:54

[root@linux ~]# ldconfig [-f conf] [ -C cache] [-p]

参数:

-f conf  : conf指的是某个文件名称,也就是说,使用conf作为libarary

           函数库的取得路径,而不以 /etc/ld.so.conf为默认值

-C cache : cache指的是某个文件名称,也就是说,使用cache作为高速缓存暂存

           函数库信息,而不以 /etc/ld.so.cache为默认值

-p       : 列出当前所拥有的所有函数库数据内容(在 /etc/ld.so.cache中的数据)。

范例:

 

范例一:假设MySQL数据库函数库在 /usr/lib/mysql中,如何读入高速缓存?

[root@linux ~]# vi /etc/ld.so.conf

include ld.so.conf.d/*.conf

/usr/lib/mysql   <==这一行是新增的。

 

刷新动态库:

[root@linux ~]# ldconfig

# 画面上不会显示任何信息,正常。

 

[root@linux ~]# ldconfig -p

928 libs found in cache `/etc/ld.so.cache'

        libz.so.1 (libc6) => /usr/lib/libz.so.1

        libz.so (libc6) => /usr/lib/libz.so

...... 中间省略 ......

通过上面的操作,我们可以将 MySQL 的相关函数库读入高速缓存中,这样可以加快函数库读取的速度。有时您可能会自行加入某些 Tarball 安装的动态函数库,当您想让这些动态函数库的相关连接可以读入到高速缓存中时,可以将动态函数库所在的目录名称写入  /etc/ld.so.conf 中,然后执行 ldconfig
root@ubuntu:/zlab_16t2/changqingteng# echo "/usr/local/lib" | tee /etc/ld.so.conf.d/freesasa.conf /usr/local/lib root@ubuntu:/zlab_16t2/changqingteng# ldconfig -v | grep freesasa /sbin/ldconfig.real: Can't stat /usr/local/lib/i386-linux-gnu: No such file or directory /sbin/ldconfig.real: Path `/usr/lib/i386-linux-gnu' given more than once (from /etc/ld.so.conf.d/i386-linux-gnu.conf:4 and /etc/ld.so.conf.d/i386-linux-gnu.conf:3) /sbin/ldconfig.real: Can't stat /usr/local/lib/i686-linux-gnu: No such file or directory /sbin/ldconfig.real: Can't stat /lib/i686-linux-gnu: No such file or directory /sbin/ldconfig.real: Can't stat /usr/lib/i686-linux-gnu: No such file or directory /sbin/ldconfig.real: Path `/usr/local/lib' given more than once (from /etc/ld.so.conf.d/libc.conf:2 and /etc/ld.so.conf.d/freesasa.conf:1) /sbin/ldconfig.real: Can't stat /usr/local/lib/x86_64-linux-gnu: No such file or directory /sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once (from /etc/ld.so.conf.d/x86_64-linux-gnu.conf:4 and /etc/ld.so.conf.d/x86_64-linux-gnu.conf:3) /sbin/ldconfig.real: Path `/usr/lib32' given more than once (from /etc/ld.so.conf.d/zz_i386-biarch-compat.conf:3 and /etc/ld.so.conf.d/zz_i386-biarch-compat.conf:2) /sbin/ldconfig.real: Path `/lib/x86_64-linux-gnu' given more than once (from <builtin>:0 and /etc/ld.so.conf.d/x86_64-linux-gnu.conf:3) /sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once (from <builtin>:0 and /etc/ld.so.conf.d/x86_64-linux-gnu.conf:3) /sbin/ldconfig.real: Path `/usr/lib' given more than once (from <builtin>:0 and <builtin>:0) /sbin/ldconfig.real: /lib/i386-linux-gnu/ld-linux.so.2 is the dynamic linker, ignoring /usr/local/lib: (from /etc/ld.so.conf.d/freesasa.conf:1) /sbin/ldconfig.real: /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 is the dynamic linker, ignoring /sbin/ldconfig.real: /lib32/ld-linux.so.2 is the dynamic linker, ignoring 请分析错误原因,并给出详细解决步骤
最新发布
07-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值