LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
在 VC 下面编译一个 Console 程序, 出现如上的错误, 实在有点莫名其妙:
MSDN KB Q167946
http://support.microsoft.com/default.aspx?scid=kb;en-us;167946
FIX: ATL Service EXE Doesnt Build in Release Build
The information in this article applies to:
Microsoft Visual C++, 32-bit Enterprise Edition 5.0
Microsoft Visual C++, 32-bit Professional Edition 5.0
This article was previously published under Q167946
SYMPTOMS
If you try to build a release mode of an ATL service EXE created with ATL COM AppWizard, you get the following the error message:
"error LNK2001: unresolved external symbol _main"
CAUSE
Builds in release mode automatically include the preprocessor directive _ATL_MIN_CRT, while the default ATL service code generated by the wizard requires the CRT library.
RESOLUTION
Remove _ATL_MIN_CRT from the list the preprocessor defines to allow CRT startup code to be included.
From the Project menu, click Settings.
In the Settings For drop-down list, select Multiple Configurations.
In the Select project configuration(s) to modify dialog box that displays, select the check boxes for all release versions, and then click OK.
Click the C/C++ tab in the Project Settings dialog box, and then choose the General category.
Remove _ATL_MIN_CRT from the Preprocessor definitions edit box.
NOTE: You can also remove calls to the CRT functions within the generated CServiceModule::LogEvent function.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was corrected in Visual C++ version 6.0 for Windows.
MORE INFORMATION
Steps to Reproduce Behavior
Create a Server EXE project using ATL COM Appwizard.
Build one of the release builds.
The error listed in the SYMPTOMS section should occur.
REFERENCES
For additional information about using CRT in ATL projects, please see the following article(s) in the Microsoft Knowledge Base:
165076 INFO: LNK2001 Error ATL Release Build
Last Reviewed: 10/15/2002
Keywords: kbBug kbVC600fix KB167946