Reputation: 325
I've been working on the prototypes of an app that makes use of SDL and winsock libraries when I was suddenly met with this error on compilation:
LNK2019 unresolved external symbol main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
I tried changing the "SubSystem" option to Windows and Console so forth, but that only resulted in the same error with a different "unresolved external symbol WinMain" message. After some research I listened the advice of someone to change the main to wmain and voila - the app was working as intended.
What makes me curious is that I didn't change any default settings from Visual Studio except for the C++ standard (which I changed from C++11 to C++17), and my other projects that do have "Use Unicode Character Set" option turned on do work with a normal main() function. So what exactly forces me to use wmain instead of the usual main here?
Upvotes: 0
Views: 346
Reputation: 325
The problem was caused by the SDL macro that extends "main" to "SDL_main". The solution was to either use
#undef main
or use the official SDL way of undefining main. Using "wmain" seemed like it solved the problem not because of unicode dependency, but because SDL does not have a macro for "wmain".
Upvotes: 2