Unresolved external symbol main referenced in function "int __cdecl invoke_main(void)"

Hi All,

I’m trying to build my first SDL code on Windows using Visual Studio, and I’m getting error

unresolved external symbol main referenced in function “int __cdecl invoke_main(void)” (?invoke_main@@YAHXZ)

Any idea what could be the problem? My super simple piece of code is the following one.

Thanks!

Andre

#include <stdio.h>

#include “SDL.h”

int main(int argc, char* argv[])
{
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0)
{
printf(“Failed to initialize SDL - %s\n”, SDL_GetError());
return -1;
}

SDL_Quit();

return 0;

}

Hi All,

It turned out I also needed to add SDL2main.lib to the project.

Cheers,

Andre