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 http://social.msdn.microsoft.com/Forums/en/vclanguage/thread/14e85604-6929-4707-a22e-8cdf596926a6
- 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 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
- try Project + properties, C/C++, Code generation, Buffer security check = No http://social.msdn.microsoft.com/Forums/hi-IN/vclanguage/thread/e2ea62c3-beb3-47a4-8963-60b799e3375a
- 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 http://social.msdn.microsoft.com/Forums/hi-IN/vclanguage/thread/e2ea62c3-beb3-47a4-8963-60b799e3375a
- commented out headers in main.cpp except 'using namespace std' and #include - 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 except main.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 http://social.msdn.microsoft.com/Forums/ar-SA/vcgeneral/thread/105a366f-c38d-4c1c-9278-eca64589e7ca and http://social.msdn.microsoft.com/Forums/zh/Vsexpressvc/thread/341780c2-162e-4b36-9402-283c0cf7c0ac
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) http://social.msdn.microsoft.com/Forums/zh/Vsexpressvc/thread/341780c2-162e-4b36-9402-283c0cf7c0ac
- using cmake to build on windows 7 x64 http://hdf-forum.184993.n3.nabble.com/error-LNK2019-unresolved-external-symbol-main-referenced-in-function-tmainCRTStartup-td3138042.html
why am I getting this error and what is the solution?
See Question&Answers more detail:os