views:

652

answers:

2

How come I get this error when compiling with the -m32 argument?

unrecognised emulation mode: 32

I'm compiling using g++ on an x86_64 machine. It happens in one project, but not the other... Any hints?

Note: I'm using Eclipse CDT, so perhaps this is an IDE specific 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?

+1  A: 

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

For example, my ld supports the emulation modes elf_i386 and i386linux, for generating ELF binaries and a.out binaries respectively.

Johannes Schaub - litb
Hmm, somehow I managed to get it to work, no idea how... but now, when I remove the -m32 argument from the linker, it throws out hundreds of errors such as... i386 architecture of input file {file-name} is incompatible with i386:x86-64 output
nbolton
+1  A: 

It seems that in Eclipse, you must specify -m32 in the miscelanious linker options, if it's specified in the compiler options.

The "unrecognised emulation mode: 32" error message appears when your reference a library path that doesn't exist - which is weird!

nbolton