ubuntu 编译报错问题

最近在ubuntu上跑代码,当编译的时候出现了题目中的问题,在CSDN上搜到的解决方案可谓是“天下一大抄”,这抄那里,那抄这里,全都一样,而且没有解释明白这个报错是什么意思,光说了一些出现该提醒可能的原因(且提到的原因我感觉驴唇不对马嘴)。所以逼得我去科学上网,用Google搜索了一下,结果第一个回答就解决了疑惑。下面分享给没法科学上网的朋友们。

简单来说,collect2 error ld returned 1 exit status提示出现之前,一般在上面几行都会有其他报错,而collect2 error ld returned 1 exit status所反映的只是其之前一共出现了多少个错误,真正的错误是在其上面出现的那些报错。比如,没有错误,会提示collect2 error ld returned 0 exit status;有两个报错,会提示collect2 error ld returned 2 exit status。所以,真正要解决的是在collect2 error ld returned 1 exit status提示出现之前的那些报错提醒。

以下是Google回答的原文:

The ld returned 1 exit status error is the consequence of your previous errors as in your example there is an earlier error - undefined reference to 'clrscr' - and this is the real one. The exit status error just signals that the linking step in the build process encountered some errors. Normally exit status 0 means success, and exit status > 0 means errors. Various tools may be running while creating a program as separate steps to create the final executable. In your case one of those tools is ld, which first reports the error it found (clrscr reference missing), and then it returns the exit status. Since the exit status is > 0, it means an error and is reported.

In many cases tools return as the exit status the number of errors they encountered. So if the old tool finds two errors, its exit status would be 2.

原回答的链接:(需科学上网)What does collect2 error ld returned 1 exit status mean | Edureka Community
————————————————
版权声明:本文为CSDN博主「间歇努力为了持续躺平」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_45055622/article/details/126634000

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值