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

13,206

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.

Share:
13,206
Admin
Author by

Admin

Updated on June 19, 2022

Comments

  • Admin
    Admin almost 2 years

    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>
    
  • karlphillip
    karlphillip over 9 years
    Also, it's important that Character Set be configured to Use Multi-Byte Character Set.