为什么我会在 Eclipse 中收到“无法识别的仿真模式:32”错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/663811/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why do I get the "unrecognised emulation mode: 32" error in Eclipse?
提问by Nick Bolton
How come I get this error when compiling with the -m32 argument?
使用 -m32 参数编译时为什么会出现此错误?
unrecognised emulation mode: 32
无法识别的仿真模式:32
I'm compiling using g++ on an x86_64 machine. It happens in one project, but not the other... Any hints?
我正在 x86_64 机器上使用 g++ 进行编译。它发生在一个项目中,而不是另一个项目中......有什么提示吗?
Note:I'm using Eclipse CDT, so perhaps this is an IDE specific gocha?
注意:我使用的是 Eclipse CDT,所以这可能是 IDE 特定的 gocha?
Rephrased question
改写的问题
Perhaps a better question would be: What is the best method of building an x86 binary in Eclipse when running on an x86_64 machine?
也许更好的问题是:在 x86_64 机器上运行时,在 Eclipse 中构建 x86 二进制文件的最佳方法是什么?
回答by Nick Bolton
It seems that in Eclipse, you must specify -m32 in the miscelanious linker options, if it's specified in the compiler options.
似乎在 Eclipse 中,如果在编译器选项中指定了 -m32,则必须在杂项链接器选项中指定 -m32。
The "unrecognised emulation mode: 32" error message appears when your reference a library path that doesn't exist - which is weird!
当您引用不存在的库路径时,会出现“无法识别的仿真模式:32”错误消息 - 这很奇怪!
回答by Johannes Schaub - litb
In the one project, you are passing the -m
to the linker accidentally. The GNU linker (ld) supports an -m option for specifying the emulation mode. An emulation consists of a linker script, output object file format and parameters for it - like the start address. Watch not to put -m
to LDFLAGS but to CXXFLAGS (C++ compiler flags) or CFLAGS (c compiler flags).
在一个项目中,您-m
意外地将 传递给链接器。GNU 链接器 (ld) 支持用于指定仿真模式的 -m 选项。仿真由链接描述文件、输出目标文件格式和它的参数组成——比如起始地址。注意不要放入-m
LDFLAGS,而是放入CXXFLAGS(C++ 编译器标志)或 CFLAGS(c 编译器标志)。
For example, my ld
supports the emulation modes elf_i386 and i386linux, for generating ELF binaries and a.out binaries respectively.
例如,myld
支持仿真模式 elf_i386 和 i386linux,分别用于生成 ELF 二进制文件和 a.out 二进制文件。