Visual Studio projects - C++

A Visual Studio project is a project based on the MSBuild build system. MSBuild is the native build system for Visual Studio and is generally the best build system to use for UWP apps as well as Desktop applications that use MFC or ATL libraries, COM components, and other Windows-specific programs. MSBuild is tightly integrated with Visual Studio, but you can also use it from the command line.

Create a project

You can create C++ projects by choosing File > New > Project, then setting the Language to C++. In the results list you see a list of project templates which you can filter by setting the Platform or Project Type and by typing keywords into the search box.

Visual Studio 2019 Project Templates

You can create C++ projects by choosing File > New > Project, then choosing Visual C++ in the left pane. In the center pane you see a list of project templates:

Project Templates

For more information about all the default project templates that are included in Visual Studio, see C++ project templates in Visual Studio. You can create your own project templates. For more information, see How to: Create project templates.

After you create a project, it appears in the Solution Explorer window:

Solution Explorer

When you create a new project, a solution file (.sln) is also created. You can add additional projects to the solution by right-clicking on it in Solution Explorer. The solution file is used to coordinate build dependencies when you have multiple related projects but doesn't do much more than that. All the compiler options are set at the project level.

Add items

Add source code files, icons, or any other items to your project by right-clicking on the project in Solution Explorer and choosing Add > New or Add > Existing.

Add third party libraries

To add third-party libraries, use the vcpkg package manager. Run the Visual Studio integration step to set up the paths to that library when you reference it from any Visual Studio project.

Set compiler options and other build properties

To configure build settings for a project, right-click on the project in Solution Explorer and choose Properties. For more information, see Set C++ compiler and build properties in Visual Studio.

Compile and run

To compile and run the new project, press F5 or click the debug dropdown with the green arrow on the main toolbar. The configuration dropdown is where you choose whether to perform a Debug or Release build (or some other custom configuration).

A new project compiles without errors. When adding your own code, you may occasionally introduce an error or trigger a warning. An error prevents the build from completing; a warning does not. All errors and warnings will appear both in the Output Window and in the Error List when you build the project.

Output window and error list

In the Error List, you can press F1 on a highlighted error to go to its documentation topic.

In This Section

Set C++ compiler and build properties in Visual Studio
How to use Property Pages and Property Sheets to specify your project settings.

Reference libraries and components at build time
How to include libs, DLLs, COM and .NET components in a project.

Organize Project Output Files
How to customize the location of the executable files created in the build process.

Custom Build Steps and Build Events
How to add any arbitrary command to the build process at specified points.

Create a project from existing code
How to create a new Visual Studio project from a loose collection of source files.

See also

Projects and build systems