Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
366 views
in Technique[技术] by (71.8m points)

c++ - SDL2: LNK1561: entry point must be defined

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...