在32位平台上编译64位二进制文件。

时间:2022-09-26 12:06:04

Is it possible to compile a 64-bit binary on a 32-bit Linux platform using gcc?

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

4 个解决方案

#1


23  

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.

如果安装了multilib GCC,只需向命令行添加-m64即可。如果编译器没有使用multilib支持来构建,它应该会抱怨。

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.

为了链接,您将需要标准库的所有64位对等项。如果您的发行版有一个multilib GCC,那么这些也应该在存储库中。

#2


2  

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.

进入Synaptic并搜索gcc-multilib或g++-multilib并安装包,如果-m64选项不起作用。然后,使用-m64选项进行编译。

#3


1  

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

您将需要在64位机器上编译的gcc,例如x86_64 linux-gcc。检查你的分发包经理。

#4


0  

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

我想你可以先安装gcc-multilib pachage。然后用gcc -m64你的代码编译你的代码,你可以用你的程序检查精灵的文件,输出应该是这样的你的程序:精灵64位LSB可执行,……

#1


23  

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.

如果安装了multilib GCC,只需向命令行添加-m64即可。如果编译器没有使用multilib支持来构建,它应该会抱怨。

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.

为了链接,您将需要标准库的所有64位对等项。如果您的发行版有一个multilib GCC,那么这些也应该在存储库中。

#2


2  

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.

进入Synaptic并搜索gcc-multilib或g++-multilib并安装包,如果-m64选项不起作用。然后,使用-m64选项进行编译。

#3


1  

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

您将需要在64位机器上编译的gcc,例如x86_64 linux-gcc。检查你的分发包经理。

#4


0  

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

我想你可以先安装gcc-multilib pachage。然后用gcc -m64你的代码编译你的代码,你可以用你的程序检查精灵的文件,输出应该是这样的你的程序:精灵64位LSB可执行,……