Reputation: 47186
As title said, I have C program complied and created a binary in 64-bit machine.Will this binary work under 32-bit ?
Upvotes: 1
Views: 1536
Reputation: 63538
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.
Upvotes: 1
Reputation: 64394
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
).
Upvotes: 6
Reputation: 5111
The compiling machine does not matter. What matters is: is the code generated 32 bits (answer: yes) or 64 bits (answer: no).
Upvotes: 5