开发者

Will a program complied in 64-bit work on 32-bit machine?

As title said, I have C program compl开发者_如何转开发ied and created a binary in 64-bit machine.Will this binary work under 32-bit ?


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).


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜