$ make
g++ main.cpp -I/mingw/include -L/mingw/lib -w -Wall -lSDL2main -lSDL2 -o test
/usr/lib/../lib/libmsys-2.0.a(libcmain.o): In function `main':
/msys_scripts/msys2-runtime/src/msys2-runtime/winsup/cygwin/lib/libcmain.c:37: undefined reference to `WinMain'
/msys_scripts/msys2-runtime/src/msys2-runtime/winsup/cygwin/lib/libcmain.c:37:(.text.startup+0x94): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `WinMain'
collect2: error: ld returned 1 exit status
The difference between Mingw Tutorial and mine is '-lmingw32' option.
But There is no 'mingw32' file in MSYS2.
How to solve it?
There are 2 versions or gcc toolchain: Cygwin alike msys/gcc
and native mingw-w64-i686-gcc
, mingw-w64-x86_64-gcc
.
In your case you will need to install mingw-w64-*
toolchain and use MINGW32 or MINGW64 shell depending on arch.