首页 > 解决方案 > 将 64 位 NASM 与 MinGW-64 链接会导致“文件格式无法识别”错误

问题描述

我正在尝试使用 MinGW-64bit 和以下批处理命令在 Windows 上组装和链接 64 位 NASM 程序:

nasm -f win64 HelloWorld.asm && "C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin\gcc.exe" HelloWorld.obj -o HelloWorld.exe

但我得到这个错误:

HelloWorld.obj: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status

我怎样才能解决这个问题?

标签: assemblymingw

解决方案


事实证明,虽然我下载并安装了 MinGW-64,但我仍然得到了 32 位版本,因为我在安装时选择了 i686 选项。我使用“x86-64”选项重新安装并解决了问题。


推荐阅读