700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > (已解决)报错:collect2 error ld returned 1 exit status

(已解决)报错:collect2 error ld returned 1 exit status

时间:2024-05-25 04:47:04

相关推荐

(已解决)报错:collect2 error ld returned 1 exit status

最近在VSCode上跑C++代码,当编译的时候出现了题目中的问题,在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回答的原文:

Theld returned 1 exit statuserror 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. Normallyexit status 0means success, andexit status> 0means 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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。