(已解决)报错: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回答的原文:
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
總結
以上是生活随笔為你收集整理的(已解决)报错:collect2 error ld returned 1 exit status的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PayPal的一些注意事项
- 下一篇: SQL安全-关闭外网对1433的访问