I have the following error:
LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
There are a lot of threads relating to this error, but none of those solutions worked for me. And, none explained why this error is here.
I tried:
wWinMainCRTStartup
as entry point in the linker properties (thread)- set the linker to "Windows" (same thread as above)
- Right click on solution name->Add->Existing Item->file with main (same thread as above)
#include <tchar.h>
(error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup)- try Project + properties, C/C++, Code generation, Buffer security check = No (thread)
- Options: C/C++, Code generation, Runtime library=/MTd; C/C++, Code generation, Basic Runtime Checks=default; C/C++, Code generation, Buffer security check=No; Linker, Advanced, Entry Point=main (thread)
- commented out headers in
main.cpp
exceptusing namespace std
and#include <iostream>
- results in cascading and snowballing error from functions that referencing those headers - I deleted everything in
main.cpp
except test code, and excluded all source files exceptmain.cpp
; as expected it worked, so a small step in the right direction. The problem must be with one of the header files. - create new project with Win32 Windows application template (thread and thread)
Have not tried and suspect that these also will not work:
- use
int main()
(not sure what they mean, file name or main function name) (thread) - using
cmake
to build on Windows 7 x64 (thread)
Why am I getting this error, and what is the solution?