Search code examples
c++visual-studiovisual-studio-2008visual-c++visual-studio-express

How to solve the "unresolved external symbol" link error in visual c++?


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 )
{
}

Solution

  • 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 )