让我们分析“collect2:ld returned 1 exit status”? [英] let's analyse "collect2: ld returned 1 exit status"?

查看:3764
本文介绍了让我们分析“collect2:ld returned 1 exit status”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这表明链接器问题,大多是未解决的符号。我知道,为了解决这个问题/摆脱这种错误,人们将不得不提供更多的信息。我知道有很多问题,以解决这个问题已经SO。



我的问题旨在帮助理解make和ld,找出什么(和谁)

  collect2:ld退回1退出状态




  • collect2:是什么意思?这是一个步骤调用吗?我在系统上找不到该名称的可执行文件。

  • 这是否意味着我使用ld?我配置了我的项目/ Makefile,使g ++应该链接,所以为什么LD仍然涉及

  • 谁在写这条消息?使? ld?


解决方案 / div>

首先,你需要知道命名为 gcc g ++ 只是围绕实际预处理器/解析器编译器/汇编器/链接器命令的伞(包装器)。他们的真实姓名是 cpp cc1 cc1plus code>分别作为和 ld 。 GCC有助于统一它们的使用,命令行界面并为它们提供一组有意义的默认(和必要)部分。例如,使用ld直接链接一个二进制文件是非常困难的,如果ld不是与所有20+(IIRC)正确的选项一起运行的,它只是无效。



现在你知道了,你可以看到:


这是否意味着我使用ld?我配置了我的项目/ Makefile,使g ++应该做链接,所以为什么LD仍然涉及


这意味着你调用GCC,反过来它调用LD。 GCC本身什么也不知道 - 既不编译,也不连接,因为它只是一个包装。 (Go在 / usr / bin / gcc 上做一个 wc -c ,并且惊讶它只有几个千字节!现在对 / usr / libexec / gcc / cc1plus 做同样的事情,并找出可怕的真相:它是几十个大的!)


collect2:是什么意思?这是一个步骤调用吗?我在系统上找不到具有该名称的可执行文件。


Collect2也是gcc和ld之间的另一个间接级别。 有关其官方网站的详情


谁在写这封邮件?使? ld? g ++?


可以是g ++(就我所知而言)或 collect2


$ b


是否有可能的退出代码有意义的列表?
$ b

意义是常规的 -​​ 零意味着成功,非零意味着失败。如果存在详尽列表,则应该能够通过调用 man ld 来查看。


I know this indicates a linker problem, mostly unresolved symbols. I know that to resolve that problem / to get rid of that errormessage, one would have to provide much more information. I know there is a lot of questions on resolving this problems on SO already.

My questions aims at helping to understand make and ld, to find out what (and who) is trying to express what with this line.

collect2: ld returned 1 exit status

  • What does "collect2:" mean? Is it a step make invokes ? I can't find an executable with that name on my system.
  • Does it mean I am using ld ? I configured my project / Makefile so that g++ should do the linking, so why is LD still involved
  • Who is writing that message ? make ? ld ? g++ ?
  • Is there a meaningful list of possible exit codes ?

解决方案

First things first, you need to know that the command-line programs named gcc and g++ are only umbrella (wrappers) around the actual preprocessor/parser-compiler/assembler/linker commands. Their real name is cpp, cc1 or cc1plus, as and ld, respectively. GCC helps in unifying their use, command line interface and providing a meaningful set of default (and required) otions for them. It is very hard, for example, to link a binary directly using ld - if ld is not run with all the 20+ (IIRC) correct options, it just fails to work.

Now that you know that, you can see:

Does it mean I am using ld ? I configured my project / Makefile so that g++ should do the linking, so why is LD still involved

It rather means you invoke GCC but in turn it invokes LD. GCC itself knows nothing - neither compiling, neither linking, as it's just a wrapper. (Go do a wc -c on /usr/bin/gcc and be surprised that it's only a few kilobytes! Now do the same for /usr/libexec/gcc/cc1plus and find out the horrifying truth: it is several 10 megs big!)

What does "collect2:" mean? Is it a step make invokes ? I can't find an executable with that name on my system.

Collect2 is also another level of indirection between gcc and ld. More about it on its official website.

Who is writing that message ? make ? ld ? g++ ?

Either g++ (that's it as far as I know) or collect2 itself maybe.

Is there a meaningful list of possible exit codes ?

The meaning is conventional - zero means success, nonzero means failure. If an exhaustive list exists, it should be able to be viewed by invoking man ld.

这篇关于让我们分析“collect2:ld returned 1 exit status”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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