SDL2: LNK1561: entry point must be defined

Dmitry picture Dmitry · Sep 7, 2013 · Viewed 32.9k times · Source

I want to compile this code:

#include <SDL.h>

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

But it can't be linked: Error 1 error LNK1561: entry point must be defined

There is some strange code in this library: http://hg.libsdl.org/SDL/file/75726efbf679/include/SDL_main.h

#define main    SDL_main

Also I added SDL2.lib;SDL2main.lib to Project Settings => Linker => Input.

What can I do to run this project?
VS 2012 SP3, empty C++ project.

Answer

4pie0 picture 4pie0 · Sep 7, 2013

According to this thread on Dream.In.Code:

Right click on project name -> Properties -> Expand Linker tab -> System -> SubSystem: make sure that it is Console (/SUBSYSTEM:CONSOLE)

Alternatively, if you want to hide the console window or are debugging a multithreaded application, you should set the SubSystem to Window (/SUBSYSTEM:WINDOW) instead.