“ collect2:错误:ld返回1退出状态”的含义是什么?意思? [英] What does "collect2: error: ld returned 1 exit status" mean?

查看:1773
本文介绍了“ collect2:错误:ld返回1退出状态”的含义是什么?意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到错误 collect2:错误:ld经常返回1个退出状态。例如,我正在执行以下代码段:

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("\nHi..\n");
      break;
    case 1:
      printf("\n\na");
      break;
    case 2:
      printf("\nb\n");
      break;
    case 3:
      printf("\nc");
      break;
  }
}

我明白了:

main.c:(.text+0x33): undefined reference to `clrscr'                       
collect2: error: ld returned 1 exit status 

这是什么意思?

推荐答案

ld返回1个退出状态错误是先前错误的结果。在您的示例中,有一个更早的错误-对 clrscr的未定义引用-这是真实的错误。退出状态错误仅表示构建过程中的链接步骤遇到了一些错误。通常退出状态0 表示成功,而退出状态> 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆