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

被折叠的 条评论
为什么被折叠?



