码迷,mamicode.com
首页 > 其他好文 > 详细

binutils使用错误:this linker was not configured to use sysrootscollect2:ld returned 1 exit status

时间:2014-07-27 11:45:33      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:this linker was not   c compiler cannot cr   


binutils错误,使用gcc -o 连接目标文件时,报错: /usr/local/bin/ld  :this  linker was not configured to use sysrootscollect2:ld returned 1 exit status


也有报错为:  C compiler cannot create executables  


这个可能是你/usr/local/bin 目录下的有另一个版本不对应的GNU Linker ld ,

同时你的环境变量把/usr/local/bin 设置在/usr/bin之前,或者没有设置后面那个环境变量。系统依据环境变量查找执行文件时先查找到/usr/local/bin 目录下面的ld ,这个ld的版本不对应,所以报错。
解决方法:只需把/usr/bin环境变量设置在前面,系统先查找到该目录下的ld即可。命令:export PATH="/usr/bin:$PATH"
(我还做了如下处理:先在terminal 转到/home/(username)/tool/binutils-2.16(这个根据你自己的版本情况)然后执行命令:./configure --with-sysroots  这个不是一定要的)
注:上面这种修改只在当前terminal有效。
另一种办法是:把/usr/local/bin里面的ld 改名称,这样系统在路径/usr/local/bin里面查不到 ld ,自然会执行下一个,也就是/usr/bin里面的ld
默认的/usr/bin环境变量是在/usr/local/bin环境变量之后的,第一种把/usr/bin环境变量调前只是暂时的。
命令: sudo mv /usr/local/bin/ld   /usr/local/bin/ldxxxx

(注意:要记住自己做了这种修改,否则下次因为这个出问题,自己又忘记做了这个修改,那就找破头都没办法了。)


PS:查看当前设置的环境变量:export $PATH


设置环境变量:  

cd ~

ls .pro* .bash*

gedit .profile

这样即可打开 .profile文件,然后可以在里面添加环境变量。

binutils使用错误:this linker was not configured to use sysrootscollect2:ld returned 1 exit status

标签:this linker was not   c compiler cannot cr   

原文地址:http://blog.csdn.net/u011514906/article/details/38148811

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