让我们分析一下“collect2:ld 返回 1 退出状态"? [英] let's analyse "collect2: ld returned 1 exit status"?

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

问题描述

我知道这表明存在链接器问题,主要是未解析的符号.我知道要解决该问题/摆脱该错误消息,必须提供更多信息.我知道在 SO 上解决这个问题有很多问题.

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.

我的问题旨在帮助理解 make 和 ld,找出什么(和谁)试图用这条线表达什么.

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

  • collect2:"是什么意思?它是一个步骤 make 调用吗?我在我的系统上找不到具有该名称的可执行文件.
  • 这是否意味着我正在使用 ld ?我配置了我的项目/Makefile,以便 g++ 应该进行链接,那么为什么仍然涉及 LD
  • 谁在写这条消息?制作 ?ld?g++ ?
  • 是否有一个有意义的可能退出代码列表?
  • 推荐答案

    首先,你需要知道名为 gccg++ 的命令行程序是只有实际预处理器/解析器编译器/汇编器/链接器命令周围的伞(包装器).他们的真名分别是cppcc1cc1plusasld.GCC 有助于统一它们的使用、命令行界面并为它们提供一组有意义的默认(和必需)选项.例如,直接使用 ld 链接二进制文件是非常困难的 - 如果 ld 没有使用所有 20+ (IIRC) 正确选项运行,它只是无法工作.

    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) options 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:

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

    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

    这意味着您调用了 GCC,但反过来它又调用了 LD.GCC 本身一无所知——既不编译也不链接,因为它只是一个包装器.(在 /usr/bin/gcc 上执行 wc -c 并惊讶于它只有几千字节!现在对 /usr/libexec 执行相同的操作/gcc/cc1plus 并找出可怕的真相:它有几个 10 兆大!)

    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!)

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

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

    Collect2 也是 gcc 和 ld 之间的另一个间接级别.更多关于它的官方网站.

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

    谁在写这条消息?制作 ?ld?g++ ?

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

    可能是 g++(据我所知就是这样)或 collect2 本身.

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

    是否有一个有意义的可能退出代码列表?

    Is there a meaningful list of possible exit codes ?

    含义是常规的 -​​ 零表示成功,非零表示失败.如果存在详尽的列表,则应该可以通过调用 man ld 来查看它.

    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 返回 1 退出状态"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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