Gcc ubuntu上的ld无法识别的仿真模式/tmp/ccK2pwtc.o

Gcc ubuntu上的ld无法识别的仿真模式/tmp/ccK2pwtc.o,gcc,linker,ld,Gcc,Linker,Ld,我正在使用以下机器: 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

我正在使用以下机器:

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.

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

调用链接器时,将使用
-m
选项,然后是已编译的中间对象文件(
/tmp/ccJI1LRo.o
),而不是支持的模拟,这会导致您遇到错误消息


链接器的
-m
选项需要一个参数来指定模拟。问题列表中的输出支持模拟。

这是一个非常有用的答案。我很抱歉花了这么长时间才接受