问题
I am trying to compile SDL_ttf with MinGW and Code::Blocks. I have imported the MSVC Solution to Code::Blocks, There were three projects.
- SDL_ttf
- showfont
- glfont
the SDL_ttf
project compiled fine after adding the SDL headers to the path and linking with SDL.a
. Now whenever I try to compile glfont
or showfont
I get:
undefined reference to `WinMain@16`
From the SDL FAQ I understood that this problem may occur when you do not link with SDLmain.a
, so I linked with it, but I'm still getting the error. Any suggestions? I'm completely lost.

回答1:
The problem seems similar to something you encounter in MSVS, in that you have to declare the main function as:
int _tmain(int argc, _TCHAR* argv[])
or
int wmain(int argc, _TCHAR* argv[])
The environment tries to call this function and not main()
and since you haven't implemented it, the linking error occurs.
来源:https://stackoverflow.com/questions/9037622/undefined-reference-to-winmain16-when-compiling-sdl-ttf