0

I have the following main function:

int main(int argv, char** argc) {
MainGame mainGame;
mainGame.run();

system("pause");
return 0;
}

it throw a LNK2019 unresolved _main at me.

now i did a bit of google-ing and found countless examples of people having accidentlyt setup win32 applications instead of the intended console app, so I checked mine in linker->system->subsystem and it read console.

Todegal
  • 44
  • 1
  • 9
  • 1
    Do you include anything that can redefine `main`? Seeing `MainGame mainGame;` I 'd guess you use `sdl`, if so try `#undef main` – DimChtz Aug 02 '16 at 23:52
  • Show the compiler and linker command lines. And btw, `lnk2019` suggests you are using some version of VC++, but you should specify that in the question. – dxiv Aug 02 '16 at 23:54
  • So, did you actually add the file that contains your `main` to the project you are trying to compile? – AnT stands with Russia Aug 02 '16 at 23:55
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Ken White Aug 03 '16 at 00:27
  • *I did a bit of google-ing* - Apparently not for the error message you got (LNK2019), which has dozens of existing questions here related to that same exact error. Perhaps you should work on your Google skills? – Ken White Aug 03 '16 at 00:28
  • 3
    Is it just me or is it bugging you that the general arguments to main are flipped! int argc, char* argv, lol! – Omid CompSCI Aug 03 '16 at 00:30
  • @OmidCompSCI Only the names are switched not the types, so it's ok, not good but ok :P – DimChtz Aug 03 '16 at 00:31
  • @DimChtz thats what I meant, but still bugs me! – Omid CompSCI Aug 03 '16 at 00:32
  • okay but how do i fix it – Todegal Aug 03 '16 at 13:58

1 Answers1

0

Had a similar problem when using SDL. I've added #undef main after #include "SDL.h" since main was defined inside SDL for some other purpose (as DimChtz pointed out in the comments). It solved the problem.

By the way, this does not have to be SDL-specific. Some other included header or source file in your project could also be #define-ing "main", which would trigger this behavior.