【问题标题】:ld unrecognized emulation mode /tmp/ccK2pwtc.o on ubuntuld 无法识别的仿真模式 /tmp/ccK2pwtc.o 在 ubuntu
【发布时间】:2020-08-04 16:53:28
【问题描述】:

我正在使用以下机器:

Linux version 5.4.0-42-generic (buildd@lgw01-amd64-038) (gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2)) #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020

程序

int main() {
  return 0;
}

编译时

gcc -Wl,-m main.c

返回

/usr/bin/ld: unrecognised emulation mode: /tmp/ccJI1LRo.o
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu elf_l1om elf_k1om i386pep i386pe
collect2: error: ld returned 1 exit status

我不知道从哪里开始知道为什么。

还有 gcc 和 ld 版本:

> gcc --version
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

> ld --version
GNU ld (GNU Binutils for Ubuntu) 2.34
Copyright (C) 2020 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

【问题讨论】:

    标签: gcc linker ld


    【解决方案1】:

    -Wl,-m 参数指定 gcc 应将 -m 参数传递给链接器。

    调用链接器时,会使用 -m 选项,然后是一个已编译的中间目标文件 (/tmp/ccJI1LRo.o),而不是受支持的仿真,这会导致您收到错误消息遇到过。

    链接器的-m 选项需要一个参数来指定仿真。您问题中的输出列出了支持的仿真。

    【讨论】:

    • 这是一个非常有用的答案。很抱歉花了这么长时间才接受
    猜你喜欢
    • 2019-06-21
    • 1970-01-01
    • 2016-04-13
    • 2021-09-18
    • 2010-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-01
    相关资源
    最近更新 更多