Daniel Williams
Daniel Williams

Reputation: 665

Linking 64-bit NASM with MinGW-64 causes "File format not recognized" error

I am trying to assemble and link a 64-bit NASM program on Windows using MinGW-64bit with the following batch command:

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

But I get this error:

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

How can I fix this?

Upvotes: 3

Views: 1015

Answers (1)

Daniel Williams
Daniel Williams

Reputation: 665

It turns out that, although I downloaded and installed MinGW-64, I still got a 32-bit version because I selected the i686 option upon installation. I reinstalled with the "x86-64" option and it fixed the problem.

Upvotes: 4

Related Questions