views:

71

answers:

2

Which option should be enabled in gcc to generate 16-bit or 32-bit or 64-bit object code ? Are there separate options for generating each of the above object code type ?

+1  A: 

To force gcc to generate 32-bit code you would give it the -m32 flag. To force it to generate 64-bit code you would give it the -m64 flag. I don't know of any option for 16-bit.

rettops
+4  A: 

The bitness of the generated object code is determined by the target architecture selected when gcc was built. If you want to build for a different platform, you should build a cross compiler for your desired target platform.

Note, however, that GCC does not support 16-bit x86, and that if both 32-bit and 64-bit x86 compilers are installed, as an exception, you can use -m32 or -m64 to select the desired target format.

bdonlan
Is it mandatory to have the 32-bit or 64-bit x86 compilers to be installed to get the respective 32-bit or 64-bit object code ?
S.Man
Yes. `-m32` or `-m64` just tells GCC to invoke the appropriate cross-compiler. Most Linux distributions will have a way to install both.
bdonlan
@bdonian you only need the x86_64 compiler to use `-m32`
Spudd86