SDL2: LNK1561: entry point must be defined

后端 未结 6 1892
天命终不由人
天命终不由人 2020-12-09 04:18

I want to compile this code:

#include 

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

But it can\'t be linked: Erro

6条回答
  •  独厮守ぢ
    2020-12-09 05:01

    DON'T #undef main! while its a really bad practice on the SDL side to redefine it, they have good reasons: WinMain is defined on the library side and used to run some init code, helping with compatibility issues. (even more when using different SDL implementations, like Steam's or porting to other platforms like Android)

    So what should you do? When on Windows, you should always include SDL2main.lib before SDL2.lib and make sure your main is in the format:

    int main(int argc, char* argv[]) // CORRECT
    void main(int argc, char* argv[]) // WRONG
    int main(int, char**) // MAY BE CORRECT
    

    Source: SDL2 Windows FAQ

提交回复
热议问题