Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

GCC: Generate 32-bit code in 64-bit environment

📅 2012-Dec-15 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ gcc, ubuntu, x86, x86-64 ⬩ 📚 Archive

When the gcc compiler is used on 64-bit Linux that is running on a x86-64 processor, it produces 64-bit code by default. To request it to produce 32-bit code that can be executed on a x86 processor, use the -m32 option:

$ gcc -m32 main.c

For this command to be successful, your Linux installation needs to have the necessary 32-bit libraries needed for gcc to link with.

Tried with: gcc 4.6.3 and Ubuntu 12.04 LTS x64

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧