3

I Have the Visual Studio C++ 2008 Express Edition.

I am trying to compile a program but I am getting the following Link Error:

1>MSVCRT.lib(wcrtexew.obj) : error LNK2001: unresolved external symbol _wWinMain@16

What I tried to do:

I found this on google:

For Visual C++ .NET: In the Advanced category of the Linker folder in the Project Properties dialog box, set the Entry Point to wWinMainCRTStartup.

It was intended to work but didn't. How do I compile this app?

The code is stupidly simple:

#include "stdafx.h"
int main( int argc, char ** argv )
{
}
Victor
  • 1,655
  • 9
  • 26
  • 38

3 Answers3

8

There are multiple ways to solve this:

  1. Create a console application
  2. Change the Subsystem console now in the linker settings ( Project Settings -> Linker -> System -> SubSystem (select Console))
  3. Change the entry point in the linker settings to mainCRTStartup (Project Settings -> Linker -> Advanced -> Entry Point)
  4. Define int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow ); instead of int main(int argc, char const ** argv)

  5. Change the Character Set to Use Unicode Character Set (Project Settings -> General->Character Set )

Vinzenz
  • 2,749
  • 17
  • 23
3

It looks like when you created your project you selected a GUI (Win32, MFC, etc) program. Those programs have a WinMain() instead of a main().

What you want is a Console project.

Adam
  • 16,808
  • 7
  • 52
  • 98
1

According to similar questions, that error happens when main isn't defined.

Maybe for some reason it's compiling a different file?

This answer suggests that maybe your flags are inconsistent.

Community
  • 1
  • 1
Brendan Long
  • 53,280
  • 21
  • 146
  • 188