“collect2:错误:ld 返回 1 个退出状态"是什么意思?意思是? [英] What does "collect2: error: ld returned 1 exit status" mean?
问题描述
我经常看到错误 collect2: error: ld returned 1 exit status
.例如,我正在执行以下代码片段:
I see the error collect2: error: ld returned 1 exit status
very often. For example, I was executing the following snippet of code:
void main() {
char i;
printf("ENTER i");
scanf("%c",&i);
clrscr();
switch(i) {
default:
printf("
Hi..
");
break;
case 1:
printf("
a");
break;
case 2:
printf("
b
");
break;
case 3:
printf("
c");
break;
}
}
我得到了这个:
main.c:(.text+0x33): undefined reference to `clrscr'
collect2: error: ld returned 1 exit status
什么意思?
推荐答案
ld returns 1 exit status
错误是先前错误的结果.在您的示例中,有一个较早的错误 - undefined reference to 'clrscr'
- 这是真正的错误.退出状态错误只是表明构建过程中的链接步骤遇到了一些错误.通常exit status 0
表示成功,exit status
> 0表示错误.
The ld returned 1 exit status
error is the consequence of previous errors. 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.
当您构建程序时,多个工具可能会作为单独的步骤运行以创建最终的可执行文件.在您的情况下,其中一个工具是 ld
,它首先报告它发现的错误(clrscr
引用丢失),然后返回退出地位.由于退出状态> 0,表示有错误,并上报.
When you build your program, multiple tools may be run 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.
在许多情况下,工具会返回它们遇到的错误数量作为退出状态.因此,如果 ld 工具发现两个错误,其退出状态将为 2.
In many cases tools return as the exit status the number of errors they encountered. So if ld tool finds two errors, its exit status would be 2.
这篇关于“collect2:错误:ld 返回 1 个退出状态"是什么意思?意思是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!