Is it possible to compile a 64 bit executable on a

2019-03-04 16:58发布

问题:

And, if it is possible, can you please point me to an example of this? Thanks!

回答1:

What you are looking for is cross compilation. http://en.wikipedia.org/wiki/Cross_compiler#GCC_and_cross_compilation

As Tomas said, you need the libs of the target machine installed and assuming you are using gcc you will need to use the "-b machine" option, and probably a few other options also (man gcc, and spend a lot of time reading!).

This can be a real pain to get right, so i would ask whether it is really necessary?



回答2:

No, it isn't possible because you need specific x86_64 libraries that can't be used in a 32 bit system.

Believe it or not, you can build 32 bit binaries in a 64 bit system.

You should check this https://wiki.archlinux.org/index.php/Arch64_FAQ#Can_I_build_32-bit_packages_for_i686_inside_Arch64.3F and http://www.linuxquestions.org/questions/linux-hardware-18/compiling-64-bit-kernel-in-32-bit-linux-240183/

Is not ubuntu specific, but is similar.