error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup, but this time it's NOT a Windows/Console problem!

浪尽此生 提交于 2019-11-28 05:02:35

SDL_main.h is included automatically from SDL.h, so you always get the nasty #define.

Just write:

#include <SDL.h>
#undef main

And it should work fine

Another option would actually to define your own main with the usual parameters

int main(int argc, char *args[])
{
    // Your code here
}

That should get rid of the error.

Then if you don't use those parameters and you also want to get rid of the compiler warning you could do that trick in your main function.

(void)argc;
(void)args;

The culprit is likely to be SDL_main.h. Check that you don't include that file, there is a nasty define there:

#define main SDL_main
#define SDL_MAIN_HANDLED
#include "SDL.h"

https://wiki.libsdl.org/SDL_SetMainReady

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!