I want to compile this code:
#include
int main(int argc, char* argv[]) {
return 0;
}
But it can\'t be linked: Erro
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