Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 )
{
}
like image 740
Victor Avatar asked Oct 18 '25 14:10

Victor


2 Answers

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 )

like image 102
Vinzenz Avatar answered Oct 21 '25 03:10

Vinzenz


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.

like image 24
Adam Avatar answered Oct 21 '25 03:10

Adam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!