码迷,mamicode.com
首页 > 系统相关 > 详细

Linux编译问题——/usr/bin/ld: cannot find -lxxx问题总结

时间:2014-12-09 00:36:33      阅读:534      评论:0      收藏:0      [点我收藏+]

标签:style   io   ar   color   os   sp   strong   on   文件   

  作者:zhanhailiang 日期:2014-12-08

make时报“/usr/bin/ld: cannot find -lxxx”,是指编译过程找不到对应库文件,其中,-lxxx表示链接库文件libxxx.so。

一般出现这种错误有以下几种原因:

  1. 系统缺乏对应的库文件;
  2. 版本不对应;
  3. 库文件的链接错误;
  4. 库文件路径设置问题。

前两种情况只需要下载安装lib库即可(一般地,yum install libxxx-dev或apt-get install libxxx-dev直接安装即可)

排除掉前两种情况后,请确认后两种情况:

第三种情况,通过find或者locate指令定位到链接文件,查看链接文件是否正确的指向了我们希望的lib,如果不是,用 ln -sf */libxxx.so.x */libxxx.so 指令修改它。

第四种情况,如果是库文件路径引发的问题,可以到/etc/ld.so.conf.d目录下,修改其中任意一份conf文件,(可以自建conf,以方便识别)将lib所在目录写进去,然后在终端输入 ldconfig 更新缓存。

具体实例,今天编译php遇到如下错误“/usr/bin/ld: cannot find -lltdl”,如下:

/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [sapi/fpm/php-fpm] Error 1

这是因为缺少ltdl库,执行 yum install libtool-ltdl-devel.x86_64 即可。

Linux编译问题——/usr/bin/ld: cannot find -lxxx问题总结

标签:style   io   ar   color   os   sp   strong   on   文件   

原文地址:http://blog.csdn.net/billfeller/article/details/41812615

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!