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!!