64位linux下编译32位程序

I had to compile a 32-bit application using GNU gcc on the 64-bit version Linux.

Luckily gcc man page directed me to -m32 and -m64 option. These options generate code for a 32-bit or 64-bit environments.

=> The 32-bit environment sets int, long and pointer to 32 bits and generates code that runs on any i386 system.

=> The 64-bit environment sets int to 32 bits and long and pointer to 64 bits and generates code for AMD's x86-64 architecture.

You can pass -m64 or -m32 as follows
For 32 bit version:
$ gcc -m32 -o output32 hello.c
For 64 bit version :
$ gcc -m64 -o output64 hello.c

猜你喜欢

转载自blog.csdn.net/mzr122/article/details/89917772