Visual Studio Windows desktop application (Visual C++) LNK2019 error

How to replicate. Work through Microsoft’s walk-through to create a traditional Windows Desktop application (C++)

Go to File –> New –> Project

Select Visual C++ –> Windows Desktop –> Windows Desktop Wizard

Give the project a suitable name, for example, “TestOne”

Visual Studio 2017 Create Desktop Project Wizard
Visual Studio 2017 Create Desktop Project Wizard

By default the application type is set to “Console Application (.exe)”.

Windows Desktop Project Application Type
Windows Desktop Project Application Type

If you don’t change the application type to “Windows Application (.exe)” you will get an unresolved external symbol _main LINK2019 error when you build the solution. The linker looking for _mainĀ  thinks that the project is building a console application.

To fix this make sure the projects linker properties for the subsystem is set to Windows instead of console. Go to Project –>Properties –> Linker –> System and change the subsystem to Windows.

Visual Studio Project Properties Linker Subsystem
Visual Studio Project Properties Linker Subsystem

 

You May Also Like

About the Author: George