/usr/bin/ld: cannot find -lX11解决方法
来源:互联网 发布:php性能测试代码 编辑:程序博客网 时间:2024/06/05 09:36
编译代码的时候链接阶段出现了问题,/usr/bin/ld: cannot find -lX11,看到这个信息时心里很是纳闷,在/usr/lib/路径下明明有libX11.so.6,为什么没有链接到呢,再三思索,最后想起-lX11其实代表的是全名是libX11.so,而/usr/lib/下确实没有这个文件,如果你不写-lX11,而是写/usr/lib/libX11.so.6,那么链接的时候链接器会准确的找到动态库。
其实.so结尾的文件应该是安装了开发库的话才会有的,平常我们安装软件其实下载的只是头文件,只供一般使用,所以出现这个错误在我的电脑中是因为没有安装开发库,执行
yum install libX11-devel.i686
安装完毕后程序链接成功,让我们再回到/usr/lib库看看,安装过后你会发现确实多了.so结尾的动态库,用ls -l /usr/lib/libX11.so显示
lrwxrwxrwx 1 root root 15 2月 28 11:08 /usr/lib/libX11.so -> libX11.so.6.3.0
其实它是个符号连接,指向本路径中的libX11.so.6.3.0。
再看看编译出的二进制文件依赖哪些动态库,执行ldd XXXXX
linux-gate.so.1 => (0xb77d1000)
libX11.so.6 => /lib/libX11.so.6 (0x43dde000)
libncurses.so.5 => ./lib/libncurses.so.5 (0x4702a000)
可执行文件真正加载的是/lib/libX11.so.6,不是/usr/lib/libX11.so.6.3.0,很奇怪,不过让我们再看看/lib/libX11.so.6到底是什么,执行
ls -l /lib/libX11.so.6
输出 lrwxrwxrwx 1 root root 15 2月 28 03:07 /lib/libX11.so.6 -> libX11.so.6.3.0
原来它也是连接文件,与libX11.so指向不同路径下的同一个文件。
所以以后当你遇到这种情况,首先确定自己是否安装了开发库,然后看看版本对不对,这里面的符号连接是不是都是指向同一个动态库的。如果有问题一定是这3个原因中的一个。
1 系统没有安装相对应的lib
2 相对应的lib版本不对
3 lib(.so档)的symbolic link 不正确,没有连结到正确的函式库文件(.so)
- /usr/bin/ld: cannot find -lX11解决方法
- /usr/bin/ld: cannot find -lX11
- usr/bin/ld: cannot find 错误解决方法
- usr/bin/ld: cannot find 错误解决方法
- usr/bin/ld: cannot find 错误解决方法
- /usr/bin/ld: cannot find -lmysqlclient 解决方法
- usr/bin/ld: cannot find 错误解决方法
- /usr/bin/ld: cannot find -lmysqlclient解决方法
- usr/bin/ld: cannot find 错误解决方法
- /usr/bin/ld: cannot find -l* 错误的解决方法
- /usr/bin/ld:cannot find -lGL的解决方法
- /usr/bin/ld: cannot find -lcrypto 错误的解决方法
- Linux提示 /usr/bin/ld:cannot find-lxxx 系列解决方法
- 遇到usr/bin/ld: cannot find -lcufft解决方法。
- /usr/bin/ld: cannot find -lm的解决方法
- /usr/bin/ld: cannot find -l* 错误的解决方法
- /usr/bin/ld: /usr/bin/ld: cannot find -lc
- /usr/bin/ld: cannot find -lstdc++ /usr/bin/ld: cannot find -lm /usr/bin/ld: cannot find -lc
- 做leetcode的几点体会分享
- Hibernate -- 二级缓存
- Oracle安装(3)快速搭建Data Gurad之物理standby
- Android 代码风格指南
- jquery 实用收藏
- /usr/bin/ld: cannot find -lX11解决方法
- 编程入门:学习编程,从何入手
- English Introduce
- 修正IE6 IE7的window.resize bug
- Eclipse下Android开发,如何查看 API源代码、私有库源代码 文件 (android source & private libs source)
- boost::intrusive_ptr用法
- BZOJ1025: [SCOI2009]游戏
- 垂直领域的差异化推广
- Android Breakpad dmp文件转文本文件