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
@@ -31,11 +31,11 @@ Causes the compiler to process [`#pragma omp`](../../preprocessor/omp.md) direct
31
31
32
32
::: moniker range=">= msvc-160"
33
33
34
-
The C++ compiler currently supports the OpenMP 2.0 standard. However, Visual Studio 2019 also now offers SIMD functionality. To use SIMD, compile by using the **`/openmp:experimental`** option. This option enables both the usual OpenMP features, and OpenMP SIMD features not available when using the **`/openmp`** switch.
34
+
The C++ compiler currently supports the OpenMP 2.0 standard. Visual Studio 2019 also now offers SIMD functionality. To use SIMD, compile using the **`/openmp:experimental`** option. This option enables both the usual OpenMP features, and OpenMP SIMD features not available when using the **`/openmp`** switch.
35
35
36
36
Starting in Visual Studio 2019 version 16.9, you can use the experimental **`/openmp:llvm`** option instead of **`/openmp`** to target the LLVM OpenMP runtime. Support currently isn't available for production code, since the required libomp DLLs aren't redistributable. The option supports the same OpenMP 2.0 directives as **`/openmp`**. And, it supports all the SIMD directives supported by the **`/openmp:experimental`** option. It also supports unsigned integer indices in parallel for loops according to the OpenMP 3.0 standard. For more information, see [Improved OpenMP Support for C++ in Visual Studio](https://devblogs.microsoft.com/cppblog/improved-openmp-support-for-cpp-in-visual-studio/).
37
37
38
-
Currently, the **`/openmp:llvm`** option only works on the x64 architecture. The option isn't compatible with **`/clr`** or **`/ZW`**.
38
+
The **`/openmp:llvm`** option supports the x64 architecture. Starting with Visual Studio 2019 version 16.10, it also supports the x86 and ARM64 architectures. This option isn't compatible with **`/clr`** or **`/ZW`**.
Copy file name to clipboardExpand all lines: docs/build/vscpp-step-1-create.md
+19-14Lines changed: 19 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -2,35 +2,40 @@
2
2
title: Create a C++ console app project
3
3
description: "Create a Hello World console app using Microsoft C++ in Visual Studio."
4
4
ms.custom: "mvc"
5
-
ms.date: 04/20/2020
5
+
ms.date: 07/05/2023
6
6
ms.topic: "tutorial"
7
-
ms.assetid: 45138d70-719d-42dc-90d7-1d0ca31a2f54
8
7
---
9
8
# Create a C++ console app project
10
9
11
-
The usual starting point for a C++ programmer is a "Hello, world!" application that runs on the command line. That's what you'll create in Visual Studio in this step.
10
+
The usual starting point for a C++ programmer is a "Hello, world!" application that runs on the command line. That's what you create in Visual Studio in this step.
12
11
13
12
## Prerequisites
14
13
15
14
- Have Visual Studio with the Desktop development with C++ workload installed and running on your computer. If it's not installed yet, see [Install C++ support in Visual Studio](vscpp-step-0-installation.md).
16
15
17
16
## Create your app project
18
17
19
-
Visual Studio uses *projects* to organize the code for an app, and *solutions* to organize your projects. A project contains all the options, configurations, and rules used to build your apps. It manages the relationship between all the project's files and any external files. To create your app, first, you'll create a new project and solution.
18
+
Visual Studio uses *projects* to organize the code for an app, and *solutions* to organize your projects. A project contains all the options, configurations, and rules used to build your apps. It manages the relationship between all the project's files and any external files. To create your app, first, create a new project and solution.
20
19
21
20
::: moniker range=">=msvc-160"
22
21
23
22
1. In Visual Studio, open the **File** menu and choose **New > Project** to open the **Create a new Project** dialog. Select the **Console App** template that has **C++**, **Windows**, and **Console** tags, and then choose **Next**.
24
23
25
-

24
+
:::image type="complex" source="media/vs2019-choose-console-app.png" alt-text="Screenshot of the create a new project dialog.":::
25
+
The create a new project dialog with the Console App template selected. That template says: Run code in a windows terminal. Prints hello world by default. Has the tags c++, Windows, and Console.
26
+
:::image-end:::
26
27
27
28
1. In the **Configure your new project** dialog, enter *HelloWorld* in the **Project name** edit box. Choose **Create** to create the project.
28
29
29
-

30
+
:::image type="complex" source="media/vs2019-configure-new-project-hello-world.png" alt-text="Screenshot of Configure your new project dialog.":::
31
+
The Configure your new project dialog with HelloWorld entered into the Project name field.
32
+
:::image-end:::
30
33
31
-
Visual Studio creates a new project. It's ready for you to add and edit your source code. By default, the Console App template fills in your source code with a "Hello World" app:
34
+
Visual Studio creates a new project. It's ready for you to add and edit your source code. By default, the Console App template provides source code for a "Hello World" app, like this:
32
35
33
-

36
+
:::image type="complex" source="media/vs2019-hello-world-code.png" alt-text="Screenshot of the NEW Hello World project.":::
37
+
Shows the new project. The HelloWorld.cpp file is open, showing the default code that is included with this template. That code consists of #include iostream and a main() function that contains the line: std::cout << quote hello world!\n quote;
38
+
:::image-end:::
34
39
35
40
When the code looks like this in the editor, you're ready to go on to the next step and build your app.
36
41
@@ -48,7 +53,7 @@ Visual Studio uses *projects* to organize the code for an app, and *solutions* t
48
53
49
54

50
55
51
-
Visual Studio creates a new, empty project. It's ready for you to specialize for the kind of app you want to create and to add your source code files. You'll do that next.
56
+
Visual Studio creates a new, empty project. It's ready for you to specialize for the kind of app you want to create and to add your source code files. You do that next.
52
57
53
58
[I ran into a problem.](#create-your-app-project-issues)
54
59
@@ -62,7 +67,7 @@ Visual Studio can create all kinds of apps and components for Windows and other
62
67
63
68

64
69
65
-
Visual Studio now knows to build your project to run in a console window. Next, you'll add a source code file and enter the code for your app.
70
+
Visual Studio now knows to build your project to run in a console window. Next, you add a source code file and enter the code for your app.
66
71
67
72
[I ran into a problem.](#make-your-project-a-console-app-issues)
68
73
@@ -94,15 +99,15 @@ Visual studio creates a new, empty source code file and opens it in an editor wi
94
99
95
100
The code should look like this in the editor window:
96
101
97
-

102
+
 function that contains the line: std::cout << \"hello world!\n\"; followed by return 0;")
98
103
99
104
When the code looks like this in the editor, you're ready to go on to the next step and build your app.
100
105
101
106
[I ran into a problem.](#add-a-source-code-file-issues)
102
107
103
108
::: moniker-end
104
109
105
-
## Next Steps
110
+
## Next steps
106
111
107
112
> [!div class="nextstepaction"]
108
113
> [Build and run a C++ project](vscpp-step-2-build.md)
@@ -119,7 +124,7 @@ The **New Project** dialog should show a **Console App** template that has **C++
119
124
120
125
To install **Desktop development with C++**, you can run the installer right from the **New Project** dialog. Choose the **Install more tools and features** link at the bottom of the template list to start the installer. If the **User Account Control** dialog requests permissions, choose **Yes**. In the installer, make sure the **Desktop development with C++** workload is checked. Then choose **Modify** to update your Visual Studio installation.
121
126
122
-
If another project with the same name already exists, choose another name for your project. Or, delete the existing project and try again. To delete an existing project, delete the solution folder (the folder that contains the *helloworld.sln* file) in File Explorer.
127
+
If another project with the same name already exists, choose another name for your project. Or, delete the existing project and try again. To delete an existing project, delete the solution folder (the folder that contains the `helloworld.sln` file) in File Explorer.
123
128
124
129
[Go back](#create-your-app-project).
125
130
@@ -133,7 +138,7 @@ If the **New Project** dialog doesn't show a **Visual C++** entry under **Instal
133
138
134
139
::: moniker range="<=msvc-150"
135
140
136
-
If another project with the same name already exists, choose another name for your project. Or, delete the existing project and try again. To delete an existing project, delete the solution folder (the folder that contains the *helloworld.sln* file) in File Explorer.
141
+
If another project with the same name already exists, choose another name for your project. Or, delete the existing project and try again. To delete an existing project, delete the solution folder (the folder that contains the `helloworld.sln` file) in File Explorer.
Copy file name to clipboardExpand all lines: docs/build/vscpp-step-2-build.md
+28-9Lines changed: 28 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,9 @@
2
2
title: Build and run a C++ console app project
3
3
description: "Build and run a Hello World console app in Visual C++"
4
4
ms.custom: "mvc"
5
-
ms.date: 04/20/2020
5
+
ms.date: 07/05/2023
6
6
ms.topic: "tutorial"
7
7
ms.devlang: "cpp"
8
-
ms.assetid: 45138d71-719d-42dc-90d7-1d0ca31a2f55
9
8
---
10
9
# Build and run a C++ console app project
11
10
@@ -15,7 +14,7 @@ You've created a C++ console app project and entered your code. Now you can buil
15
14
16
15
- Have Visual Studio with the Desktop development with C++ workload installed and running on your computer. If it's not installed yet, follow the steps in [Install C++ support in Visual Studio](vscpp-step-0-installation.md).
17
16
18
-
- Create a "Hello, World!" project and enter its source code. If you haven't done this step yet, follow the steps in [Create a C++ console app project](vscpp-step-1-create.md).
17
+
- Create a "Hello, World!" project. By default, it contains code to print `Hello World!`. If you haven't done this step yet, follow the steps in [Create a C++ console app project](vscpp-step-1-create.md).
19
18
20
19
If Visual Studio looks like this, you're ready to build and run your app:
21
20
@@ -39,15 +38,24 @@ Congratulations! You've created your first "Hello, world!" console app in Visual
39
38
40
39
## Run your code in a command window
41
40
42
-
Normally, you run console apps at the command prompt, not in Visual Studio. Once your app is built by Visual Studio, you can run it from any command window. Here's how to find and run your new app in a command prompt window.
41
+
Normally, you run console apps at the command prompt, not in Visual Studio. Once Visual Studio builds your app, you can run it from a command window. Here's how to find and run your new app in a command prompt window.
43
42
44
43
1. In **Solution Explorer**, select the HelloWorld solution (not the HelloWorld project) and right-click to open the context menu. Choose **Open Folder in File Explorer** to open a **File Explorer** window in the HelloWorld solution folder.
45
44
46
-
1. In the **File Explorer** window, open the Debug folder. This folder contains your app, *HelloWorld.exe*, and a couple of other debugging files. Hold down the **Shift** key and right-click on *HelloWorld.exe* to open the context menu. Choose **Copy as path** to copy the path to your app to the clipboard.
45
+
::: moniker range="<msvc-170"
47
46
48
-
1. To open a command prompt window, press **Windows+R** to open the **Run**dialog. Enter *cmd.exe* in the **Open**textbox, then choose **OK** to run a command prompt window.
47
+
2. In the **File Explorer** window, open the `Debug` folder. This folder contains your app, `HelloWorld.exe`, and debugging files. Hold down the **Shift**key and right-click on `HelloWorld.exe` to open the context menu. Choose **Copy as path**to copy the path to your app to the clipboard.
49
48
50
-
1. In the command prompt window, right-click to paste the path to your app into the command prompt. Press Enter to run your app.
49
+
::: moniker-end
50
+
::: moniker range=">=msvc-170"
51
+
52
+
2. In the **File Explorer** window, open the `x64` folder and then the `Debug` folder. This folder contains your app, `HelloWorld.exe`, and debugging files. Hold down the **Shift** key and right-click on `HelloWorld.exe` to open the context menu. Choose **Copy as path** to copy the path to your app to the clipboard.
53
+
54
+
::: moniker-end
55
+
56
+
3. To open a command prompt window, press **Windows+R** to open the **Run** dialog. Enter *cmd.exe* in the **Open** textbox, then choose **OK** to run a command prompt window.
57
+
58
+
4. In the command prompt window, right-click to paste the path to your app into the command prompt. Press Enter to run your app.
51
59
52
60

53
61
@@ -71,9 +79,20 @@ If red squiggles appear under anything in the source code editor, the build may
71
79
72
80
### Run your code in a command window: issues
73
81
74
-
If the path shown in File Explorer ends in *\\HelloWorld\\HelloWorld*, you've opened the HelloWorld *project* instead of the HelloWorld *solution*. You'll be confused by a Debug folder that doesn't contain your app. Navigate up a level in File Explorer to get to the solution folder, the first *HelloWorld* in the path. This folder also contains a Debug folder, and you'll find your app there.
82
+
::: moniker range="<msvc-170"
83
+
84
+
If the path shown in File Explorer ends in `\HelloWorld\HelloWorld`, you've opened the HelloWorld *project* instead of the HelloWorld *solution*. You'll be confused by a `Debug` folder that doesn't contain your app. Navigate up a level in File Explorer to get to the solution folder, the first *HelloWorld* in the path. This folder also contains a `Debug` folder, and you'll find your app there.
85
+
86
+
You can also navigate to the solution `Debug` folder at the command line to run your app. Your app won't run from other directories without specifying the path to the app. However, you can copy your app to another directory and run it from there. It's also possible to copy it to a directory specified by your `PATH` environment variable, then run it from anywhere.
87
+
88
+
::: moniker-end
89
+
::: moniker range=">=msvc-170"
90
+
91
+
If the path shown in File Explorer ends in `\HelloWorld\HelloWorld`, you've opened the HelloWorld *project* instead of the HelloWorld *solution*. You'll be confused by a `x64\Debug` folder that doesn't contain your app. Navigate up a level in File Explorer to get to the solution folder, the first `HelloWorld` in the path. This folder also contains a `x64\Debug` folder, and you'll find your app there.
92
+
93
+
You can also navigate to the solution `x64\Debug` folder at the command line to run your app. Your app won't run from other directories without specifying the path to the app. However, you can copy your app to another directory and run it from there. It's also possible to copy it to a directory specified by your `PATH` environment variable, then run it from anywhere.
75
94
76
-
You can also navigate to the solution Debug folder at the command line to run your app. Your app won't run from other directories without specifying the path to the app. However, you can copy your app to another directory and run it from there. It's also possible to copy it to a directory specified by your PATH environment variable, then run it from anywhere.
95
+
::: moniker-end
77
96
78
97
If you don't see **Copy as path** in the shortcut menu, dismiss the menu, and then hold down the **Shift** key while you open it again. This command is just for convenience. You can also copy the path to the folder from the File Explorer search bar, and paste it into the **Run** dialog, and then enter the name of your executable at the end. It's just a little more typing, but it has the same result.
0 commit comments