如何在 64 位上编译和执行 32 位 C 程序 Windows

How to compile and execute 32bit C program on 64bit Windows

我正在使用基于 Intel 的 64 位机器,并希望在我的命令提示符下编译和 运行 32 位 C 代码。我通过(Windows Linux 的子系统)安装了 bash,并且正在使用 gcc 并安装了 gcc-multilib,因此我可以使用 -m32 标签进行编译。该程序编译正常,但在我尝试 运行:

时出现此错误
bash: ./32test: cannot execute binary file: Exec format error

WSL 仅支持 64 位 ELF 二进制文件。

https://github.com/Microsoft/BashOnWindows/issues/390

您可以尝试使用本机 Windows 编译器或 Cygwin 进行构建。