[Linux]Ubuntu的ld不搜索/usr/lib/x86_64-linux-gnu的问题

Ervin posted @ 2012年3月23日 22:03 in Linux with tags gcc linux ubuntu , 19953 阅读

今天在ubuntu(for AMD64)下编译gcc-4.6.3时遇到如下错误:

/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
collect2: ld 返回 1

执行locate crt1.o,发现这两个.o文件都是在/usr/lib/x86_64-linux-gnu目录下的,难道ld没有搜索这个目录吗?将执行出错的语句手动执行并加上-v选项,发现果然没有搜索这个目录。

 

通过dpkg-query查了一下,确认这个文件是属于libc6-dev包的。难道ubuntu的gcc/ld出了什么问题?但之前也没少编译东西,没出什么问题。出于对ubuntu不太信任的心里,跑到Debian的网站上查询了libc6-dev包的情况,发现Debian AMD64版本的这个包中的这俩文件是直接安装到/usr/lib目录下的,看来这应该是个ubuntu特定的问题。

于是以"ubuntu /usr/lib/x86_64-linux-gnu"为关键词搜索,搜到这个页面:

http://askubuntu.com/questions/52617/what-is-usr-lib-i386-linux-gnu-for

果然是ubuntu特定的问题。仔细想想觉得ubuntu这么做不是很有必要,毕竟/usr/lib下的动态静态库文件必然是当前系统所使用的,既然当前系统是x86_64-linux-gnu,那就没必要在/usr/lib下再放一个x86_64-linux-gnu,把当前系统需要用的库分成了两部分。相比之下,Debian的方式就不会出现这种无厘头的问题。

继续搜索又搜到这个页面:

http://askubuntu.com/questions/69119/linking-problems-after-updating-to-11-10

跟我遇到的问题几乎一模一样,但人家那个问题是ubuntu 11.10刚出来时遇到的,而且更新gcc/binutils之后解决了。现在ubuntu 12.04都要发布了,怎么我还会遇到这个问题?前几天安装了mutilib的支持,也许可能跟这个有关,或者干脆就是源里面的gcc/binutils的bug。上面的链接中还给出了另一个解决方法,就是make之前设置LIBRARY_PATH变量,虽然不完美,但也只好如此了:

LIBRARY_PATH=/usr/lib/x86_64-linux-gnu make
Avatar_small
celebrity heights 说:
2023年6月14日 20:09

Finally find the info someone asked the other day about Johnny Depp on celeb height wiki I was looking for it all over the web and luckily found it!

Avatar_small
seo service london 说:
2024年1月16日 00:34

Nice service there are just few who are providing this service great job


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter