You receive an "error LNK2001:unresolved external symbol "_WinMain@16" message when a Console Application project is built as an Application project in Visual C++

Article translations Article translations
Article ID: 131204 - View products that this article applies to.
This article was previously published under Q131204
Expand all | Collapse all

On This Page

SYMPTOMS

The linker generates the following error message when a Console Application project is built as an Application project:
LIBC.lib(wincrt0.obj):error LNK2001:unresolved external symbol "_WinMain@16"

CAUSE

A project of type Application is a Windows-based application, so it requires the WinMain function as the entry point.

RESOLUTION

Create a new project and select Console Application as the Project Type, or add a project to the existing Project.

To Create a new target for an existing project with Visual C++ 2.x, from the Project menu, choose Targets, and select New. Enter a Target Name, and choose Win32 Console Application as the type. To build the new target, move to the project dialog box, change the Target to your new Target name, and rebuild.

To add a project with Visual C++ 5.0 or 6.0, select Project, then Add to Project, and select New. Click on the Projects tab and select Win32 Console Application.

To create a new project in Visual C++ .NET, see the online help topic on "Creating Win32 Projects".

STATUS

This behavior is by design.

MORE INFORMATION

To reproduce the behavior, select Application as the Project Type, and use the following sample code.

Sample Code to Demonstrate Behavior

/* Compile options needed: None
*/ 

#include <iostream.h>

void main(void)
{
   cout << "Hello " ;
}
				

Properties

Article ID: 131204 - Last Review: December 9, 2005 - Revision: 5.0
APPLIES TO
  • Microsoft Visual C++ 2.0 Professional Edition
  • Microsoft Visual C++ 2.1
  • Microsoft Visual C++ 4.0 Standard Edition
  • Microsoft Visual C++ 5.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Enterprise Edition
  • Microsoft Visual C++ 5.0 Professional Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft Visual C++ .NET 2002 Standard Edition
  • Microsoft Visual C++ 2005 Express Edition
Keywords: 
kberrmsg kbtshoot kbide kbprb KB131204

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com