libmingw32
So while starting with SDL2 (w/ C++ and I am on Windows 11), getting the initial compile took a bit of time but I was able to write a working makefile.
inc = .\SDL2-2.32.10\x86_64-w64-mingw32\include
stat = .\SDL2-2.32.10\x86_64-w64-mingw32\lib
all: main.cpp
g++ main.cpp -I$(inc) -L$(stat) -o main.exe -lmingw32 -lSDL2main -lSDL2
Now apparently I wanted to understand what each of these linking are, and specifically -lmingw32 !
I definitely used AI to understand this becuz I am too fucking Lazy to Google it and browse through 10 different threads 😜 !
Now its sort of difficult for me to understand the whole thing but here is the gist of what I understood and the AI said I've got the essence of it:
So as we know main() function is the entry point of our programs. Now the OS does not directly execute main() rather it first need a startup code to reach main(). On Unix systems glibc provides that startup code but on Windows libmingw32 is the library that has the startup code.
Window's entry point is mainCRTStartup... which is provided inside libmingw32.
Even though each program is normally complied with the linking implicitly. While using SDL we need to link libmingw32 explicitly so that the startup code for WinMain() is ready before SDL wraps our main() in WinMain().
Again, I can be wrong at places as this is a not something I get fully.
Click here for Source Code.