Question

As title said, I have C program complied and created a binary in 64-bit machine.Will this binary work under 32-bit ?

Was it helpful?

Solution

64-bit binaries cannot run on a 32-bit OS. If file reports ELF 64-bit, you have a 64-bit binary.

In order to build 32-bit binaries on a 64-bit Linux, you need pass -m32 to gcc. You also need to have 32-bit libraries installed (sudo apt-get install libc6-dev-i386).

OTHER TIPS

The compiling machine does not matter. What matters is: is the code generated 32 bits (answer: yes) or 64 bits (answer: no).

Will it work on a 32-bit machine? One with a CPU which doesn't support 64-bit mode? No.

Will it work on a 64-bit VM on a 32-bit native OS? Yes, in my experience.

A surprising result is that 64-bit VMs CAN be run under a 32-bit host OS, provided the CPU is capable and you don't want to allocate too much ram (>2G or thereabouts) to the guest.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top