You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/build/creating-and-managing-visual-cpp-projects.md
+4-10Lines changed: 4 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,17 @@
1
1
---
2
2
description: "Learn more about: creating and configuring Visual Studio C++ projects"
3
3
title: "Visual Studio Projects - C++"
4
-
ms.date: 04/20/2022
4
+
ms.date: 10/4/2023
5
5
helpviewer_keywords: ["Visual Studio C++ projects, creating", "projects [C++], creating", "Visual Studio C++ projects"]
6
6
---
7
7
# Visual Studio projects - C++
8
8
9
9
A *Visual Studio project* is a collection of code files and assets such as icons, images, and so on, that are built together using the MSBuild build system. MSBuild is the native build system for Visual Studio and is generally the best build system to use for Windows-specific programs. MSBuild is tightly integrated with Visual Studio, but you can also use it from the command line.
10
10
11
-
12
11
For information about upgrading MSBuild projects from older versions of Visual Studio, see the [Microsoft C++ Porting and Upgrading Guide](../porting/visual-cpp-porting-and-upgrading-guide.md).
13
12
14
13
For cross-platform projects, or projects that use open-source libraries, we recommend using [CMake projects in Visual Studio](cmake-projects-in-visual-studio.md) in Visual Studio 2017 and later.
15
14
16
-
17
15
## Create a Visual Studio C++ project
18
16
19
17
::: moniker range=">=msvc-160"
@@ -53,13 +51,11 @@ The solution file coordinates build dependencies when you have multiple related
53
51
54
52
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**.
55
53
56
-
57
54
## Add third-party libraries to a project
58
55
59
56
Over 900 C++ open source libraries are available via the [vcpkg](https://vcpkg.io/) 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.
60
57
61
-
62
-
There are also commercial third-party libraries that you can install. Follow their installation instructions.
58
+
They're also commercial third-party libraries that you can install. Follow their installation instructions.
63
59
64
60
## Set compiler options and build properties
65
61
@@ -69,11 +65,9 @@ To configure build settings for a project, right-click on the project in **Solut
69
65
70
66
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).
71
67
68
+
A new project compiles without errors. When adding your own code, you might occasionally introduce an error or trigger a warning. An error prevents the build from completing; a warning doesn't. All errors and warnings appear both in the Output Window and in the Error List when you build the project.
72
69
73
-
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 doesn't. All errors and warnings appear both in the Output Window and in the Error List when you build the project.
74
-
75
-
76
-

70
+

77
71
78
72
In the **Error List**, you can press **F1** on the highlighted error to go to its documentation topic.
Copy file name to clipboardExpand all lines: docs/build/creating-precompiled-header-files.md
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -161,8 +161,12 @@ The code base of a software project is often contained in multiple C or C++ sour
161
161
162
162
The figure uses three diagrammatic devices to show the flow of the build process. Named rectangles represent each file or macro; the three macros represent one or more files. Shaded areas represent each compile or link action. Arrows show which files and macros are combined during the compilation or linking process.
163
163
164
-
\
165
-
Structure of a makefile that uses a precompiled header file
164
+
![ The diagram is described in the text following the diagram.]()\
165
+
Structure of a makefile that uses a precompiled header file:
166
+
167
+
:::image type="complex" source="media/vc30ow1.gif" alt-text="Diagram showing example inputs and outputs of a makefile that uses a precompiled header file.":::
168
+
The diagram shows `$(STABLEHDRS)` and `$(BOUNDRY)` feeding into CL /c /W3 /Yc$(BOUNDRY) applib.cpp myapp.cpp. The output of that is $(STABLE.PCH). Then, applib.cpp and $(UNSTABLEHDRS) and $(STABLE.PCH) feed into CL /c /w3 /Yu $(BOUNDRY) applib.cpp, which produces applib.obj. myapp.cpp, $(UNSTABLEHDR), and $(STABLE.PCH) feed into CL /c /w3 /Yu $(BOUNDRY) myapp.cpp, which produces myapp.obj. Finally, applib.obj and myapp.obj are combined by LINK /NOD ONERROR:NOEXE $(OBJS), myapp, NUL, $(LIBS), NUL to produce myapp.exe.
169
+
:::image-end:::
166
170
167
171
Beginning at the top of the diagram, both `STABLEHDRS` and `BOUNDRY` are NMAKE macros in which you list files not likely to need recompilation. These files are compiled by the command string
Copy file name to clipboardExpand all lines: docs/build/customize-cmake-settings.md
+10-6Lines changed: 10 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -14,11 +14,13 @@ If you maintain projects that use a *`CMakeSettings.json`* file for CMake build
14
14
15
15
To open the CMake settings editor, select the **Configuration** drop-down in the main toolbar and choose **Manage Configurations**.
16
16
17
-

17
+

18
18
19
19
Now you see the **Settings Editor** with the installed configurations on the left.
20
20
21
-

21
+
:::image type="complex" source="media/cmake-settings-editor.png" alt-text="Screenshot of the CMake settings editor.":::
22
+
The left pane shows the installed configurations (x86-Debug). The right pane shows the settings for the selected configuration. The settings include the configuration name, configuration type (set to Debug), toolset (set to msvc_x86), CMake toolchain file (empty), build root (contains ${env:USERPROFILE}\CMakeBuilds\${workspaceHash}\build\${name}), CMake command arguments (empty), and build command arguments (-v).
23
+
:::image-end:::
22
24
23
25
Visual Studio provides one `x64-Debug` configuration by default. You can add more configurations by choosing the green plus sign. The settings that you see in the editor might vary depending on which configuration is selected.
24
26
@@ -34,7 +36,7 @@ Corresponds to the **name** setting. This name appears in the C++ configuration
34
36
35
37
### Configuration type
36
38
37
-
Corresponds to the **configurationType** setting. Defines the build configuration type for the selected generator. Currently supported values are "Debug", "MinSizeRel", "Release", and "RelWithDebInfo". It maps to [`CMAKE_BUILD_TYPE`](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html).
39
+
Corresponds to the **configurationType** setting. Defines the build configuration type for the selected generator. Currently supported values are Debug, MinSizeRel, Release, and RelWithDebInfo. It maps to [`CMAKE_BUILD_TYPE`](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html).
38
40
39
41
### Toolset
40
42
@@ -96,7 +98,7 @@ Corresponds to **generator**. Maps to the CMake **`-G`** switch, and specifies t
96
98
- "Visual Studio 14 2015 Win64"
97
99
- "Visual Studio 14 2015 ARM"
98
100
99
-
Because Ninja is designed for fast build speeds instead of flexibility and function, it's set as the default. However, some CMake projects may be unable to correctly build using Ninja. If that occurs, you can instruct CMake to generate a Visual Studio project instead.
101
+
Because Ninja is designed for fast build speeds instead of flexibility and function, it's set as the default. However, some CMake projects might be unable to correctly build using Ninja. If that occurs, you can instruct CMake to generate a Visual Studio project instead.
100
102
101
103
### IntelliSense mode
102
104
@@ -190,8 +192,10 @@ You can also directly edit *`CMakeSettings.json`* to create custom configuration
190
192
191
193
JSON IntelliSense helps you edit the *`CMakeSettings.json`* file:
192
194
193
-

194
-
195
+
:::image type="complex" source="media/cmake-json-intellisense.png" alt-text="Screenshot of the CMake JSON IntelliSense pop-up in the editor.":::
196
+
The JSON IntelliSense pop-up for "configurations" shows buildCommandArgs, buildRoot, cmakeCommandArgs, configurationType, among several others.
197
+
:::image-end:::
198
+
195
199
For more information about each of the properties in the file, see [`CMakeSettings.json` schema reference](cmakesettings-reference.md).
0 commit comments