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
You can build C and C++ applications on the command line by using tools that are included in Visual Studio. You can also download the compiler toolset as a standalone package from the [Visual Studio downloads](https://visualstudio.microsoft.com/downloads/) page. It is part of the **Build Tools for Visual Studio** package; you can choose to download only the tools you need for C++ development.
11
+
You can build C and C++ applications on the command line by using tools that are included in Visual Studio. The compiler toolset is also downloadable as a standalone package from the [Visual Studio downloads](https://visualstudio.microsoft.com/downloads/) page. It's part of the **Build Tools for Visual Studio** package. You can choose to download only the tools you need for C++ development.
12
12
13
13
## How to use the command-line tools
14
14
15
-
When you choose one of the C++ workloads in the Visual Studio Installer, it installs the Visual Studio *platform toolset*. A platform toolset has all the C and C++ tools for a specific Visual Studio version. The tools include including the C/C++ compilers, linkers, assemblers, and other build tools, and matching libraries. You can use all of these tools at the command line. They're also used internally by the Visual Studio IDE. There are separate x86-hosted and x64-hosted compilers and tools to build code for x86, x64, ARM, and ARM64 targets. Each set of tools for a particular host and target build architecture is stored in its own directory.
15
+
When you choose one of the C++ workloads in the Visual Studio Installer, it installs the Visual Studio *platform toolset*. A platform toolset has all the C and C++ tools for a specific Visual Studio version. The tools include the C/C++ compilers, linkers, assemblers, and other build tools, and matching libraries. You can use all of these tools at the command line. They're also used internally by the Visual Studio IDE. There are separate x86-hosted and x64-hosted compilers and tools to build code for x86, x64, ARM, and ARM64 targets. Each set of tools for a particular host and target build architecture is stored in its own directory.
16
16
17
17
To work correctly, the tools require several specific environment variables to be set. These variables are used to add the tools to the path, and to set include file, library file, and SDK locations. To make it easy to set these environment variables, the installer creates customized *command files*, or batch files, during installation. You can run one of these command files to set a specific host and target build architecture, Windows SDK version, and platform toolset. For convenience, the installer also creates shortcuts in your Start menu. The shortcuts start developer command prompt windows by using these command files for specific combinations of host and target. These shortcuts ensure all the required environment variables are set and ready to use.
18
18
@@ -30,46 +30,46 @@ The command prompt shortcuts are installed in a version-specific Visual Studio f
30
30
-**x86_x64 Cross Tools Command Prompt** - Sets the environment to use 32-bit, x86-native tools to build 64-bit, x64-native code.
31
31
-**x64_x86 Cross Tools Command Prompt** - Sets the environment to use 64-bit, x64-native tools to build 32-bit, x86-native code.
32
32
33
-
The Start menu folder and shortcut names vary depending on the installed version of Visual Studio, and if you set one, the installation **Nickname**. For example, suppose you installed Visual Studio 2019, and you gave it a nickname of *Latest*. The developer command prompt shortcut is named **Developer Command Prompt for VS 2019 (Latest)**, in a folder named **Visual Studio 2019**.
33
+
The Start menu folder and shortcut names vary depending on the installed version of Visual Studio. If you set one, they also depend on the installation **Nickname**. For example, suppose you installed Visual Studio 2019, and you gave it a nickname of *Latest*. The developer command prompt shortcut is named **Developer Command Prompt for VS 2019 (Latest)**, in a folder named **Visual Studio 2019**.
34
34
35
35
## <aname="developer_command_prompt"></a> To open a developer command prompt window
36
36
37
37
1. On the desktop, open the Windows **Start** menu, and then scroll to find and open the folder for your version of Visual Studio, for example, **Visual Studio 2019**.
38
38
39
39
1. In the folder, choose the **Developer Command Prompt** for your version of Visual Studio. This shortcut starts a developer command prompt window that uses the default build architecture of 32-bit, x86-native tools to build 32-bit, x86-native code. If you prefer a non-default build architecture, choose one of the native or cross tools command prompts to specify the host and target architecture.
40
40
41
-
For an even faster way to open a developer command prompt, enter *developer command prompt* in the desktop search box, then choose the result you want.
41
+
For an even faster way to open a developer command prompt, enter *developer command prompt* in the desktop search box. Then choose the result you want.
If you prefer to set the build environment in an existing command prompt window, you can use one of the command files created by the installer. We recommend you set the environment in a new command prompt window. We don't recommend you later switch environments in the same command window.
46
46
47
47
::: moniker range=">= vs-2019"
48
48
49
-
The command file location depends on the version of Visual Studio you have installed, and installation directory and nickname choices you made during installation. For Visual Studio 2019, the typical installation location on a 64-bit system is in \\Program Files (x86)\\Microsoft Visual Studio\\2019\\*edition*, where *edition* may be Community, Professional, Enterprise, BuildTools, or another nickname you supplied.
49
+
The command file location depends on the version of Visual Studio you installed, and on choices you made during installation. For Visual Studio 2019, the typical installation location on a 64-bit system is in \\Program Files (x86)\\Microsoft Visual Studio\\2019\\*edition*. *Edition* may be Community, Professional, Enterprise, BuildTools, or another nickname you supplied.
50
50
51
51
::: moniker-end
52
52
::: moniker range="= vs-2017"
53
53
54
-
The command file location depends on the version of Visual Studio you have installed, and installation directory and nickname choices you made during installation. For Visual Studio 2017, the typical installation location on a 64-bit system is in \\Program Files (x86)\\Microsoft Visual Studio\\2017\\*edition*, where *edition* may be Community, Professional, Enterprise, BuildTools, or another nickname you supplied.
54
+
The command file location depends on the version of Visual Studio you installed, and on choices you made during installation. For Visual Studio 2017, the typical installation location on a 64-bit system is in \\Program Files (x86)\\Microsoft Visual Studio\\2017\\*edition*. *Edition* may be Community, Professional, Enterprise, BuildTools, or another nickname you supplied.
55
55
56
56
::: moniker-end
57
57
::: moniker range="< vs-2017"
58
58
59
-
The command file location depends on the version of Visual Studio you have installed, and installation directory choice you made during installation. For Visual Studio 2015, the typical installation location is in \\Program Files (x86)\\Microsoft Visual Studio 14.0.
59
+
The command file location depends on the Visual Studio version, and the installation directory. For Visual Studio 2015, the typical installation location is in \\Program Files (x86)\\Microsoft Visual Studio 14.0.
60
60
61
61
::: moniker-end
62
62
63
-
The primary developer command prompt command file, VsDevCmd.bat, is located in the Common7\\Tools subdirectory of the installation directory. When no parameters are specified, this sets the environment and the host and target build architecture to use the 32-bit x86-native tools to build 32-bit x86 code.
63
+
The primary developer command prompt command file, VsDevCmd.bat, is located in the Common7\\Tools subdirectory. When no parameters are specified, it sets the environment to use the x86-native tools to build 32-bit x86 code.
64
64
65
65
::: moniker range=">= vs-2017"
66
66
67
-
More command files are available to set up specific build architectures, depending on the Visual Studio workloads and options you have installed. In Visual Studio 2017 and Visual Studio 2019, you'll find them in the VC\\Auxiliary\\Build subdirectory of the installation directory.
67
+
More command files are available to set up specific build architectures. The command files available depend on the Visual Studio workloads and options you've installed. In Visual Studio 2017 and Visual Studio 2019, you'll find them in the VC\\Auxiliary\\Build subdirectory.
68
68
69
69
::: moniker-end
70
70
::: moniker range="< vs-2017"
71
71
72
-
More command files are available to set up specific build architectures, depending on the Visual Studio options you have installed. In Visual Studio 2015, these are located in the VC, VC\\bin, or VC\\bin\\*architecture* subdirectories of the installation directory, where *architecture* is one of the native or cross-compiler options.
72
+
More command files are available to set up specific build architectures. The command files available depend on the Visual Studio workloads and options you've installed. In Visual Studio 2015, they're located in the VC, VC\\bin, or VC\\bin\\*architecture* subdirectories, where *architecture* is one of the native or cross-compiler options.
73
73
74
74
::: moniker-end
75
75
@@ -92,16 +92,16 @@ These command files set default parameters and call VsDevCmd.bat to set up the s
92
92
93
93
## Use the developer tools in an existing command window
94
94
95
-
The simplest way to specify a particular build architecture in an existing command window is to use the vcvarsall.bat file. You can use vcvarsall.bat to set environment variables to configure the command line for native 32-bit or 64-bit compilation. You can specify cross-compilation to x86, x64, ARM, or ARM64 processors. You can target Microsoft Store, Universal Windows Platform, or Windows Desktop platforms, specify which Windows SDK to use, and select the platform toolset version.
95
+
The simplest way to specify a particular build architecture in an existing command window is to use the vcvarsall.bat file. Use vcvarsall.bat to set environment variables to configure the command line for native 32-bit or 64-bit compilation. Arguments let you specify cross-compilation to x86, x64, ARM, or ARM64 processors. You can target Microsoft Store, Universal Windows Platform, or Windows Desktop platforms. You can even specify which Windows SDK to use, and select the platform toolset version.
96
96
97
-
If no arguments are provided, vcvarsall.bat configures the environment variables for using the current 32-bit native compiler for x86 Windows Desktop targets. However, you can use it to configure any of the native or cross compiler tools. It displays an error message if you specify a compiler configuration that's not installed or isn't available on your computer.
97
+
When used with no arguments, vcvarsall.bat configures the environment variables to use the current x86-native compiler for 32-bit Windows Desktop targets. You can add arguments to configure the environment to use any of the native or cross compiler tools. vcvarsall.bat displays an error message if you specify a configuration that's not installed or available on your computer.
This optional argument specifies the host and target architecture to use. If *architecture*is not specified, the default build environment is used. These arguments are supported:
104
+
This optional argument specifies the host and target architecture to use. If *architecture*isn't specified, the default build environment is used. These arguments are supported:
@@ -152,35 +152,35 @@ Use **-vcvars_ver=14.0** to specify the Visual Studio 2015 compiler toolset.
152
152
153
153
::: moniker-end
154
154
155
-
1. Enter the command for your preferred developer environment. For example, to build ARM code for UWP on a 64-bit platform by using the latest Windows SDK and the latest Visual Studio compiler toolset, use this command line:
155
+
1. Enter the command for your preferred developer environment. For example, to build ARM code for UWP on a 64-bit platform, using the latest Windows SDK and Visual Studio compiler toolset, use this command line:
156
156
157
157
`vcvarsall.bat amd64_arm uwp`
158
158
159
159
## Create your own command prompt shortcut
160
160
161
161
::: moniker range=">= vs-2019"
162
162
163
-
If you open the Properties dialog for one of the existing developer command prompt shortcuts, you can see the command target used. For example, the target for the **x64 Native Tools Command Prompt for VS 2019** shortcut is something similar to:
163
+
Open the Properties dialog for a developer command prompt shortcut to see the command target used. For example, the target for the **x64 Native Tools Command Prompt for VS 2019** shortcut is something similar to:
If you open the Properties dialog for one of the existing developer command prompt shortcuts, you can see the command target used. For example, the target for the **x64 Native Tools Command Prompt for VS 2017** shortcut is something similar to:
170
+
Open the Properties dialog for a developer command prompt shortcut to see the command target used. For example, the target for the **x64 Native Tools Command Prompt for VS 2017** shortcut is something similar to:
If you open the Properties dialog for one of the existing developer command prompt shortcuts, you can see the command target used. For example, the target for the **VS2015 x64 Native Tools Command Prompt** shortcut is something similar to:
177
+
Open the Properties dialog for a developer command prompt shortcut to see the command target used. For example, the target for the **VS2015 x64 Native Tools Command Prompt** shortcut is something similar to:
178
178
179
179
`%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"" amd64`
180
180
181
181
::: moniker-end
182
182
183
-
The architecture-specific batch files set the *architecture* parameter and call vcvarsall.bat. You can pass the same options to these batch files as you would pass to vcvarsall.bat, or you can just call vcvarsall.bat directly. To specify parameters for your own command shortcut, add them to the end of the command in double-quotes. For example, to set up a shortcut to build ARM code for UWP on a 64-bit platform by using the latest Windows SDK and a compiler toolset that is earlier than the current version, you need to specify the version number. Use something like this command target in your shortcut:
183
+
The architecture-specific batch files set the *architecture* parameter and call vcvarsall.bat. You can pass the same options to these batch files as you would pass to vcvarsall.bat, or you can just call vcvarsall.bat directly. To specify parameters for your own command shortcut, add them to the end of the command in double-quotes. For example, here's a shortcut to build ARM code for UWP on a 64-bit platform, using the latest Windows SDK. To use an earlier compiler toolset, specify the version number. Use something like this command target in your shortcut:
184
184
185
185
::: moniker range=">= vs-2019"
186
186
@@ -200,7 +200,7 @@ The architecture-specific batch files set the *architecture* parameter and call
200
200
201
201
Adjust the path to reflect your Visual Studio installation directory. The vcvarsall.bat file has additional information about specific version numbers.
202
202
203
-
## Commandline tools
203
+
## Command-line tools
204
204
205
205
To build a C/C++ project at a command prompt, Visual Studio provides these command-line tools:
206
206
@@ -211,10 +211,10 @@ Use the compiler (cl.exe) to compile and link source code files into apps, libra
211
211
Use the linker (link.exe) to link compiled object files and libraries into apps and DLLs.
212
212
213
213
[MSBuild](msbuild-visual-cpp.md)<br/>
214
-
Use MSBuild (msbuild.exe) and a project file (.vcxproj) to configure a build and invoke the toolset indirectly. This is equivalent to running the **Build** project or **Build Solution** command in the Visual Studio IDE. Running MSBuild from the command line is an advanced scenario and generally not recommended.
214
+
Use MSBuild (msbuild.exe) and a project file (.vcxproj) to configure a build and invoke the toolset indirectly. It's equivalent to running the **Build** project or **Build Solution** command in the Visual Studio IDE. Running MSBuild from the command line is an advanced scenario and not commonly recommended.
Use DEVENV (devenv.exe) combined with a command-line switch—for example, **/Build** or **/Clean**—to perform certain build commands without displaying the Visual Studio IDE. In general this is preferred over using MSBuild directly because you can let Visual Studio handle the complexities of MSBuild.
217
+
Use DEVENV (devenv.exe) combined with a command-line switch such as **/Build** or **/Clean**to execute certain build commands without displaying the Visual Studio IDE. In general, DEVENV is preferred over using MSBuild directly, because you can let Visual Studio handle the complexities of MSBuild.
218
218
219
219
[NMAKE](reference/nmake-reference.md)<br/>
220
220
Use NMAKE (nmake.exe) on Windows to build C++ projects based on a traditional makefile.
@@ -223,10 +223,10 @@ When you build on the command line, the F1 command isn't available for instant h
223
223
224
224
## In This Section
225
225
226
-
These articles show how to build apps on the command line, describe how to customize the command-line build environmentto use 64-bit toolsets and target x86, x64, ARM, and ARM64 platforms, and demonstrate how to use the command-line build tools MSBuild and NMAKE.
226
+
These articles show how to build apps on the command line, and describe how to customize the command-line build environment. Some show how to use 64-bit toolsets, and target x86, x64, ARM, and ARM64 platforms. They also describe use of the command-line build tools MSBuild and NMAKE.
227
227
228
228
[Walkthrough: Compiling a Native C++ Program on the Command Line](walkthrough-compiling-a-native-cpp-program-on-the-command-line.md)<br/>
229
-
Gives an example that shows how to create and compile a simple C++ program on the command line.
229
+
Gives an example that shows how to create and compile a C++ program on the command line.
230
230
231
231
[Walkthrough: Compile a C Program on the Command Line](walkthrough-compile-a-c-program-on-the-command-line.md)<br/>
232
232
Describes how to compile a program written in the C programming language.
@@ -238,7 +238,7 @@ Describes how to create and compile a C++/CLI program that uses the .NET Framewo
238
238
Describes how to create and compile a C++/CX program that uses the Windows Runtime.
239
239
240
240
[Set the Path and Environment Variables for Command-Line Builds](setting-the-path-and-environment-variables-for-command-line-builds.md)<br/>
241
-
Describes how to start a command prompt window that has the required environment variables set for command-line builds that target x86, x64, ARM, and ARM64 platforms by using a 32-bit or 64-bit toolset.
241
+
How to set environment variables to use a 32-bit or 64-bit toolset to target x86, x64, ARM, and ARM64 platforms.
0 commit comments