Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should -m32 option of gcc be used?

Tags:

c

gcc

32bit-64bit

I am writing a program which if I compile on a Suse 10 32-bit system without adding the -m32 option and execute it on Suse 10 64-bit, it works fine.

In this case, is it not required for me to add the -m32 option?

Can we execute programs built on 32-bit systems directly on their 64-bit counterparts without any side-effects? Or are there any updates or changes required?

like image 546
Jay Avatar asked Mar 11 '10 15:03

Jay


People also ask

What is the option used for in GCC?

When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker. Then the output consists of object files output by the assembler.

Which GCC option should be used to do compilation?

The different options of gcc command allow the user to stop the compilation process at different stages. Most Useful Options with Examples: Here source. c is the C program code file. -o opt: This will compile the source.

What is the use of option in compiler?

The / compiler option is used to turn on directives and specify constants. By adding this compile switch, you turn on the directive (or off, if the directive is preceded by NO).

Which option must be used to inform GCC to stop after the preprocessing stage without running the compiler proper?

If you only want some of the stages of compilation, you can use -x (or filename suffixes) to tell gcc where to start, and one of the options -c , -S , or -E to say where gcc is to stop. Note that some combinations (for example, ' -x cpp-output -E ') instruct gcc to do nothing at all.


1 Answers

There is no problems in running 32 bits executables on 64 bit OS (as long as 32 bit dynamic libraries are present and found).

-m32 is there to compile 32 bits objects on a compiler configured to compile 64 bits objects by default.

like image 88
AProgrammer Avatar answered Sep 26 '22 02:09

AProgrammer