简体   繁体   中英

gcc: Compile a 64-bit binary on 32-bit platform

是否可以使用gcc在32位Linux平台上编译64位二进制文​​件?

If you have a multilib GCC installed, it's as simple as adding -m64 to the commandline. The compiler should complain if it is not built with multilib support.

In order to link, you'll need all the 64-bit counterparts of the standard libraries. If your distro has a multilib GCC, these should also be in the repositories.

Go into Synaptic and search for gcc-multilib or g++-multilib and install the package, if the -m64 option does not work. Then, compile with the -m64 option.

You will need a gcc that will compile on 64 bits machines, eg x86_64-linux-gcc . Check your distribution package manager.

I think you could install gcc-multilib pachage first. And then compile your code using gcc -m64 yourcode , you cound check the ELF file using file yourprogram , the output should be like this yourprogram: ELF 64-bit LSB executable,.......

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM