Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell whether my GCC is compiling 64bit by default?

is there any way to know whether GCC is compiling 32 or 64bit code by default?

my GCC version is 4.1.2. my os kernel version is x86_64.

thanks.

like image 968
imagineerThat Avatar asked Dec 28 '11 18:12

imagineerThat


People also ask

How can I tell if GCC is 32 or 64 bit?

To check this, we have to type this command. gcc –v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu ........... ........... ...........

Is GCC a 64 bit compiler?

In SLES 11, the gcc and g++ compilers default to 64-bit mode compilation, while the XL C/C++ compilers defaults to 32-bit mode.

Is GCC 32-bit compiler?

The -m32 flag tells GCC to compile in 32-bit mode.

How do I specify architecture in GCC?

If gcc -v shows GCC was configured with a --with-arch option (or --with-arch-32 and/or --with-arch-64 ) then that's what will be the default. Without a --with-arch option (and if there isn't a custom specs file in use) then the arch used will be the default for the target.


2 Answers

Type gcc -v. Amongst other things, it will tell you the target platform. For instance, I get:

Target: x86_64-redhat-linux
like image 123
Oliver Charlesworth Avatar answered Oct 12 '22 03:10

Oliver Charlesworth


As @Oli said, the configuration should tell you, but it's possible to screw with that after the fact.

For belt and braces, simply compile something, and then use file to examine the output file.

like image 27
ams Avatar answered Oct 12 '22 02:10

ams