我正在尝试在 Windows 10 上的 WSL 上运行的 x86_64 Ubuntu 20.04 上构建一个 32 位可执行文件(以查看它是否运行得更快)。如果我在 g++ 中不使用 -m32 选项构建相同的代码,结果会运行。如果我用 -m32 构建它,则不会运行。以下是完整的序列:
jon@2014Laptop:~/projects/KSolve$ uname --m
x86_64
jon@2014Laptop:~/projects/KSolve$ g++ -m32 -g speeder.cpp Game.cpp KSolve.cpp -I. -o speeder
jon@2014Laptop:~/projects/KSolve$ file speeder
speeder: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV),
dynamically linked, interpreter /lib/ld-linux.so.2,
BuildID[sha1]=3212c37b68b4eb6aec34e957739275dc272ecb86, for GNU/Linux 3.2.0,
with debug_info, not stripped
jon@2014Laptop:~/projects/KSolve$ ./speeder
-bash: ./speeder: cannot execute binary file: Exec format error
jon@2014Laptop:~/projects/KSolve$