Executing a Windows executable that was compiled with the cc
compiler command (compiler installed with Mingw64 MSYS2 on Windows) results in an unexpected error.
I was compiling a slightly modified version of the "smolnes" C program (at https://github.com/binji/smolnes/blob/main/smolnes.cc) with the following command:
cc -O2 -Wall smolnes.cc -lSDL2 -g -Wno-parentheses -Wno-misleading-indentation -Wno-bool-operation -shared
on Windows 11 with Mingw64 (MSYS2).
The modification consisted of removing the J[0]=q=(u*)mmap(0,1<<20,1,1,open(F[1],0),0)+16;
line and #include <sys/mman.h>
to make it compile on Windows. It compiles as expected, but when running instead of getting the executable to work as normal, it gives me the following error:
Program 'a.exe' failed to run: The specified executable is not a valid
application for this OS platform.At line:1 char:1
+ ./a.exe
+ ~~~~~~~.
At line:1 char:1
+ ./a.exe
+ ~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedExc
eption
+ FullyQualifiedErrorId : NativeCommandFailed
There is not much information about this error so I couldn't solve it or even know why the error occurs in the first place, which is why I am posting here. Can someone help?