ldd 动态库的路径 linux

本文详细介绍了在Linux环境下,当遇到第三方库无法加载的问题时,如何通过检查和修改LD_LIBRARY_PATH、创建符号链接、编辑ld.so.conf文件等方法来解决问题,并最终确保程序正常运行。

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

 The necessary shared libraries needed by the program are searched for in the following order

o Using the environment variable LD_LIBRARY_PATH (LD_AOUT_LIBRARY_PATH for a.out programs). Except if the executable is a setuid/setgid binary, in which case it is ignored.

o From the cache file /etc/ld.so.cache which contains a compiled list of candidate libraries previously found
in the augmented library path.

o In the default path /lib, and then /usr/lib.

在linux下编程,需要加入参数如-lACE -lpthread -lrt,如果这个时候报:

$/usr/sbin/ld:Can't find -lACE,这个时候你就可以查看这三个地方,解决方面如下:

1、可以将第三方库路径加入LD_LIBRARY_PATH

2、在/lib或者/usr/lib中建立连接: ln -s /usr/share/acedir/.lib/ace.so libace.so,一定要起名字为libACE.so;如果发现so文件名为libACE-6.0.5.so,那就先建一个链接 ln -s /usr/share/acedir/.lib/libACE-6.0.5.so libACE.so,然后cp libACE.so /usr/lib;

3、将文件目录写入ld.so.conf,echo "/usr/share/acedir/.lib/" >>ld.so.conf,但是要记得/usr/share/acedir/.lib/中有libACE.so这个文件或链接;

最后,启动程序后,会报错:can't open object file or the file is not exists;

别忘了最后一步:ldconfig

OK!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值