Don't confuse MinGW and GCC. MinGW is specifically a version of GCC for Windows.
-lmingw64 -lSDL2main -lSDL2
is wrong. On MinGW you'd use -lmingw32 -lSDL2main -lSDL2
(even on 64 bit), but on Linux, you only need -lSDL2
. You don't need to guess all this, run pkg-config --libs --cflags sdl2
and it will tell you the correct flags.