What tutorial are you using? You need
-lmingw32 -lSDL2main -lSDL2
(in this order), not just -lSDL2
. This is likely what you're missing. Also an obligatory reminder that your GCC is outdated (6, while latest is 14). You can get the latest one from MSYS2.