error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartupThere was a main() in main.cpp, which was included and compiled in the project. So what happened?
Turned out that qtmaind.lib was removed from Linker Dependencies, added it back and problem solved. Don't ask me why I removed it in the first place :)
Here's my general way to solve this particular linker error when playing with Qt in Visual Studio:
- Ensure main() is defined in a file (eg: main.cpp).
- Ensure the file (eg: main.cpp) is included in the project.
- Ensure the file is really being compiled, type some garbage and build. If there are errors in the file then it's being compiled.
- Right-click the project and click Properties.
- Go to Configuration Properties -> Linker
- Go to Input, ensure Additional Dependencies has one of this entry:
- qtmaind.lib (for Debug build)
- qtmain.lib (for Release build)