On Fedora (GNU/Linux), I can compile the program using:
cc -O3 -lSDL2 -lSDL2_mixer -lSDL2_image -Wall -Werror -pedantic src/*.c -o pong
I (roughly) followed this guide: Lazy Foo' Productions - Setting up SDL 2 on MinGW
And I tried compiling it with (using mysys2):
cc src/*.c -Ii686-w64-mingw32\include -Li686-w64-mingw32\lib -lmingw32 -lSDL2 -lSDL2main -lSDL2_mixer -lSDL2_image -o pong.exe
But I get this error: In file included from i686-w64-mingw32\include/SDL2/SDL_audio.h:37, from i686-w64-mingw32\include/SDL2/SDL.h:36, from src/screenshot.c:3: src/screenshot.c: In function 'pong_Screenshot': i686-w64-mingw32\include/SDL2/SDL_thread.h:120:25: error: '_beginthreadex' undeclared (first use in this function); did you mean 'SDL_beginthread'? 120 | #define SDL_beginthread _beginthreadex | ^~~~~~~~~~~~~~ i686-w64-mingw32\include/SDL2/SDL_thread.h:144:102: note: in expansion of macro 'SDL_beginthread' 144 | #define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) | ^~~~~~~~~~~~~~~ src/screenshot.c:33:30: note: in expansion of macro 'SDL_CreateThread' 33 | SDL_Thread *thread = SDL_CreateThread(pong_SaveFile, "SaveFile", (void *) screenshot); | ^~~~~~~~~~~~~~~~ i686-w64-mingw32\include/SDL2/SDL_thread.h:120:25: note: each undeclared identifier is reported only once for each function it appears in 120 | #define SDL_beginthread _beginthreadex | ^~~~~~~~~~~~~~ i686-w64-mingw32\include/SDL2/SDL_thread.h:144:102: note: in expansion of macro 'SDL_beginthread' 144 | #define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) | ^~~~~~~~~~~~~~~ src/screenshot.c:33:30: note: in expansion of macro 'SDL_CreateThread' 33 | SDL_Thread *thread = SDL_CreateThread(pong_SaveFile, "SaveFile", (void *) screenshot); | ^~~~~~~~~~~~~~~~ i686-w64-mingw32\include/SDL2/SDL_thread.h:123:23: error: '_endthreadex' undeclared (first use in this function) 123 | #define SDL_endthread _endthreadex | ^~~~~~~~~~~~ i686-w64-mingw32\include/SDL2/SDL_thread.h:144:144: note: in expansion of macro 'SDL_endthread' 144 | #define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) | ^~~~~~~~~~~~~ src/screenshot.c:33:30: note: in expansion of macro 'SDL_CreateThread' 33 | SDL_Thread *thread = SDL_CreateThread(pong_SaveFile, "SaveFile", (void *) screenshot); | ^~~~~~~~~~~~~~~~
At first I used the āincludeā and ālibā folder from āx86_64-w64-mingw32ā, then replaced it with the folders from āi686-w64-mingw32ā, and I still get the same error. The error code says that ā_beginthreadā is undeclared, while looking into āSDL_thread.hā it seems that it should be defined under Windows 7:
#if defined(__WIN32__)
#include <process.h> /* _beginthreadex() and _endthreadex() */
#endif
#if defined(__OS2__) /* for _beginthread() and _endthread() */
#ifndef __EMX__
#include <process.h>
#else
#include <stdlib.h>
#endif
#endif