error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup error

c++, lnk2019, sdl

Solution

I think "SDL.h" internally includes "SDL_main.h", which contains a weird `#define`:

#define main SDL_main

which is almost certainly screwing up your own `main`.

Try adding `#undef main` after include "SDL.h", e.g.:

#include <SDL.h>
#undef main

Since you said you have already changed `SubSystem` to `Console`, that should be all you need.

See this question for more information.

Problem

I am programming SDL in C++ and I keep getting an error: ``` error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup ``` What can I do to resolve this? Here is my source: ``` #include <SDL.h> int main(int argc, char *argv[]){ SDL_Init(SDL_INIT_VIDEO); SDL_Window* Window = NULL; Window = SDL_CreateWindow("Render Window",0,0,1000,1000, SDL_WINDOW_SHOWN || SDL_WINDOW_FULLSCREEN); return 0; } ``` My linker and compiler seem fine, I have included console in the subsystem etc. But the error only occurs when I add: ``` #include <SDL.h> ```

Original source

Related problems