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
description: "Learn more about: creating and configuring Visual Studio C++ projects"
3
-
title: "Visual Studio Projects - C++"
4
-
ms.date: 10/4/2023
2
+
title: "Create and Configure Visual Studio C++ Projects"
3
+
description: "Learn how to create a Visual Studio C++ project, and then add code and build your project."
4
+
ms.date: 03/24/2025
5
+
ms.topic: concept-article
5
6
helpviewer_keywords: ["Visual Studio C++ projects, creating", "projects [C++], creating", "Visual Studio C++ projects"]
6
7
---
7
-
# Visual Studio projects - C++
8
+
# Visual Studio C++ projects
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
+
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 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
11
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).
12
+
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).
12
13
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.
14
+
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).
14
15
15
16
## Create a Visual Studio C++ project
16
17
17
18
::: moniker range=">=msvc-160"
18
19
19
20
1. Create a C++ project by choosing **File** > **New** > **Project**.
21
+
20
22
1. In the **Create a new project** dialog, set the **Language** dropdown to **C++**. This filters the list of project templates to C++ projects. You can filter the templates by setting the **Platform**, **Project Type**, or by entering keywords in the search box.
21
23
22
-

24
+
:::image type="content" source="../build/media/vs2019-choose-console-app.png" alt-text="Screenshot of the Create a new project wizard. The Console App project template is selected.":::
23
25
24
26
1. Select a project template, then choose **Next**.
27
+
25
28
1. On the **Configure your new project page**, enter project-specific settings such as the project name or location and then choose **Create** to create your project.
26
29
27
30
::: moniker-end
28
31
29
32
::: moniker range="msvc-150"
30
33
31
34
1. Create a C++ project by choosing **File** > **New** > **Project**.
35
+
32
36
1. Choose **Visual C++** in the left pane. In the center pane, a list of project templates appears:
33
37
34
-

38
+
:::image type="content" source="../overview/media/vs2017-new-project.png" alt-text="Screenshot of the New Project dialog, showing available project templates for C++ such as Windows Console Application.":::
35
39
36
40
::: moniker-end
37
41
38
42
For more information about the default project templates included in Visual Studio, see [C++ project templates in Visual Studio](reference/visual-cpp-project-types.md).
39
43
40
-
You can create your own project templates. For more information, see [How to: Create project templates](/visualstudio/ide/how-to-create-project-templates).
44
+
You can create your own project templates. For more information, see [Create project templates](/visualstudio/ide/how-to-create-project-templates).
41
45
42
46
After you create a project, it appears in the [Solution Explorer](/visualstudio/ide/solutions-and-projects-in-visual-studio) window:
43
47
44
-

48
+
:::image type="content" source="media/mathlibrary-solution-explorer-153.png" alt-text="Screenshot of the Solution Explorer window, showing source files, header files, and resource files.":::
45
49
46
-
When you create a new project, a solution file (.sln) is also created. A *Visual Studio solution* is a collection of one or more projects. You can add another project to the solution by right-clicking the solution name in **Solution Explorer** > **Add** > **New project**.
50
+
When you create a new project, a solution file (*`.sln`*) is also created. A *Visual Studio solution* is a collection of one or more projects. You can add another project to the solution by right-clicking the solution name in **Solution Explorer** > **Add** > **New project**.
47
51
48
52
The solution file coordinates build dependencies when you have multiple related projects. Compiler options are set at the project level.
49
53
@@ -61,28 +65,28 @@ For more information about consuming a library that you have downloaded by using
61
65
-[vcpkg in MSBuild projects](/vcpkg/users/buildsystems/msbuild-integration)
62
66
-[Tutorial: Install and use packages with MSBuild in Visual Studio](/vcpkg/get_started/get-started-msbuild)
63
67
64
-
They're also commercial third-party libraries that you can install. Follow their installation instructions.
68
+
There are also commercial third-party libraries that you can install. Follow their installation instructions.
65
69
66
70
## Set compiler options and build properties
67
71
68
-
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](working-with-project-properties.md).
72
+
To configure build settings for a project, right-click on the project in **Solution Explorer** and choose **Properties**. For more information, see [Set compiler and build properties](working-with-project-properties.md).
69
73
70
74
## Compile and run a project
71
75
72
-
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).
76
+
To compile and run the new project, press **F5** or select 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).
73
77
74
78
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.
75
79
76
-

80
+
:::image type="content" source="../overview/media/vs2017-output-error-list.png" alt-text="Screenshot of the Output window and Error list, showing a syntax error for a misplaced colon.":::
77
81
78
82
In the **Error List**, you can press **F1** on the highlighted error to go to its documentation topic.
79
83
80
-
## See also
84
+
## Related content
81
85
82
-
[Create a project from existing code](how-to-create-a-cpp-project-from-existing-code.md)\
83
-
[Set C++ compiler and build properties in Visual Studio](working-with-project-properties.md)\
84
-
[Custom build steps and build events](understanding-custom-build-steps-and-build-events.md)\
85
-
[Reference libraries and components at build time](adding-references-in-visual-cpp-projects.md)\
Copy file name to clipboardExpand all lines: docs/build/creating-precompiled-header-files.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,7 +140,7 @@ This table lists compiler options that might trigger an inconsistency warning wh
140
140
141
141
| Option | Name | Rule |
142
142
|--|--|--|
143
-
|**`/D`**| Define constants and macros | Must be the same between the compilation that created the precompiled header and the current compilation. The state of defined constants isn't checked. However, unpredictable results can occur if your files depend on the values of the changed constants. |
143
+
|**`/D`**| Define constants and macros | Must be the same between the compilation that created the precompiled header and the current compilation. The state of defined constants isn't checked. However, unpredictable results can occur if your files depend on the values of the changed constants. |
144
144
|**`/E`** or **`/EP`**| Copy preprocessor output to standard output | Precompiled headers don't work with the **`/E`** or **`/EP`** option. |
145
145
|**`/Fr`** or **`/FR`**| Generate Microsoft Source Browser information | For the **`/Fr`** and **`/FR`** options to be valid with the **`/Yu`** option, they must also have been in effect when the precompiled header was created. Subsequent compilations that use the precompiled header also generate Source Browser information. Browser information is placed in a single *`.sbr`* file and is referenced by other files in the same manner as CodeView information. You can't override the placement of Source Browser information. |
146
146
|**`/GA`**, **`/GD`**, **`/GE`**, **`/Gw`**, or **`/GW`**| Windows protocol options | Must be the same between the compilation that created the precompiled header and the current compilation. The compiler emits a warning if these options differ. |
@@ -161,7 +161,6 @@ 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
-
![ The diagram is described in the text following the diagram.]()\
165
164
Structure of a makefile that uses a precompiled header file:
166
165
167
166
:::image type="complex" source="media/vc30ow1.gif" alt-text="Diagram showing example inputs and outputs of a makefile that uses a precompiled header file.":::
helpviewer_keywords: ["base addresses [C++]", "programs [C++], preventing relocation", "semicolon [C++], specifier", "-BASE linker option", "key address size", "environment variables [C++], LIB", "programs [C++], base address", "LIB environment variable", "BASE linker option", "DLLs [C++], linking", "/BASE linker option", "@ symbol for base address", "executable files [C++], base address", "at sign symbol for base address"]
7
-
ms.assetid: 00b9f6fe-0bd2-4772-a69c-7365eb199069
8
7
---
9
8
# `/BASE` (Base address)
10
9
@@ -23,7 +22,7 @@ The **`/BASE`** linker option sets a base address for the program. It overrides
23
22
24
23
The linker issues an error if *`address`* isn't a multiple of 64K. You can optionally specify the size of the program. The linker issues a warning if the program can't fit in the size you specified.
25
24
26
-
On the command line, another way to specify the base address is by using a *base address response file*. A base address response file is a text file that contains the base addresses and optional sizes of all the DLLs your program uses, and a unique text key for each base address. To specify a base address by using a response file, use an at sign (**`@`**) followed by the name of the response file, *`filename`*, followed by a comma, then the *`key`* value for the base address to use in the file. The linker looks for *`filename`* in either the specified path, or if no path is specified, in the directories specified in the `LIB` environment variable. Each line in *`filename`* represents one DLL and has the following syntax:
25
+
On the command line, another way to specify the base address is by using a *base address response file*. A base address response file is a text file that contains the base addresses and optional sizes of all the DLLs your program uses, and a unique text key for each base address. To specify a base address by using a response file, use an at sign (**`@`**) followed by the name of the response file, *`filename`*, followed by a comma, then the *`key`* value for the base address to use in the file. The linker looks for *`filename`* in either the specified path, or if no path is specified, in the directories specified in the `LIB` environment variable. The fully qualified *`filename`* must not exceed `MAX_PATH` (260 characters). Each line in *`filename`* represents one DLL and has the following syntax:
27
26
28
27
> *`key`**`address`*\[*`size`*]**`;`***`comment`*
29
28
@@ -35,7 +34,7 @@ one 0x28000000 0x00100000 ; for DLLONE.DLL
35
34
two 0x28100000 0x00300000 ; for DLLTWO.DLL
36
35
```
37
36
38
-
If the file that contains these lines is called DLLS.txt, the following example command applies this information:
37
+
If the file that contains these lines is called `DLLS.txt`, the following example command applies this information:
39
38
40
39
```cmd
41
40
link dlltwo.obj /dll /base:@dlls.txt,two
@@ -46,9 +45,7 @@ Another way to set the base address is by using the *`BASE`* argument in a [`NAM
46
45
### To set this linker option in the Visual Studio development environment
47
46
48
47
1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
@@ -17,7 +16,7 @@ Specifies a module-definition file to the linker.
17
16
## Arguments
18
17
19
18
*`filename`*\
20
-
The name of a module-definition file (*`.def`*) to be passed to the linker.
19
+
The name of a module-definition file (*`.def`*) to be passed to the linker. When expanded, the fully qualified filename must not exceed `MAX_PATH` (260 characters).
21
20
22
21
## Remarks
23
22
@@ -28,9 +27,7 @@ To specify a *`.def`* file from within the development environment, add it to th
28
27
### To set this linker option in the Visual Studio development environment
29
28
30
29
1. Open the project's **Property Pages** dialog box. For more information, see [Set compiler and build properties](../working-with-project-properties.md).
Copy file name to clipboardExpand all lines: docs/build/reference/dynamic-deopt-linker.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,9 @@ Builds the deoptimized output after building the optimized output instead of in
33
33
34
34
This preview flag, available starting with Visual Studio 2022 Version 17.14 Preview 2, applies only to x64 projects.
35
35
36
+
IncrediBuild 10.24 supports C++ Dynamic Debugging builds.\
37
+
FastBuild v1.15 supports C++ Dynamic Debugging builds.
38
+
36
39
### Set this linker option in the Visual Studio development environment
37
40
38
41
1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
@@ -41,6 +41,9 @@ Compiling with `/dynamicdeopt` generates other binaries that are used for debugg
41
41
If you specify `/INCREMENTAL`, the compiler generates a warning and automatically turns off `/INCREMENTAL`.
42
42
If you specify `/OPT:ICF`, the compiler generates a warning that the debug experience isn't as good. This is because ICF can cause functions to be removed from the alt file, which means you can't step into them.
43
43
44
+
IncrediBuild 10.24 supports C++ Dynamic Debugging builds.\
45
+
FastBuild v1.15 supports C++ Dynamic Debugging builds.
46
+
44
47
`/dynamicdeopt` is incompatible with edit-and-continue and the following compiler switches:
@@ -43,7 +43,7 @@ Use **`PATH`** to specify a separate set of PGO counters for each unique path t
43
43
Specifies whether to use extra counters to keep an accurate count when exceptions are thrown during training. Use **`TRACKEH`** to specify extra counters for an exact count. Use **`NOTRACKEH`** to specify single counters for code that doesn't use exception handling or that doesn't run into exceptions in your training scenarios. When you specify **`/GENPROFILE`**, the default is **`TRACKEH`** . When you specify **`/FASTGENPROFILE`**, the default is **`NOTRACKEH`** .
44
44
45
45
**`PGD`**=*filename*\
46
-
Specifies a base file name for the *`.pgd`* file. By default, the linker uses the base executable image file name with a *`.pgd`* extension.
46
+
Specifies a base filename for the *`.pgd`* file. By default, the linker uses the base executable image filename with a *`.pgd`* extension. When expanded, the fully qualified filename must not exceed `MAX_PATH` (260 characters).
0 commit comments