"undefined reference to `WinMain@16' error

For a multi-system project, I am trying to run SDL2 using Code::Blocks 17.12 and g++.

SDL2.dll under C:\MinGW\bin
all SDL2 header files under C.\MinGW\include\SDL
libSDL2.a and libSDL2main.a unter C:\MinGW\lib

My Program is in the folder D:\Temp\CPP:

SDL2.dll in the same folder

including folder SDL/lib:

including folder SDL/include:
all SDL header files

Linker Settings, Compiler Settings and Search Directories are as in the screenshots.
Nonetheless, for the code

#include “SDL.h”

int main(int argc, char* argv[])
return 0;

I get an "undefined reference to `WinMain@16’ error.
I do not see anythin I could have done wrong. Can you help me, please?

Found this answer over at stackoverflow. When I added it, the exact compile problem you are having(as I did) was resolved. Here is what you can try.

This was caused by SDL defining it’s own main function in SDL_main.h. To prevent SDL from doing this, SDL_MAIN_HANDLED macro has to be defined before the SDL.h header is included. Add it to the Preprocessor defined symbols in the C/C++ Build → Settings compiler section.