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 use Visual Studio 2017 to edit, compile and build any C++ code base with full IntelliSense support without having to convert that code into a Visual Studio project or use MSVC to compile it. For example, you can edit a CMake project in Visual Studio on your local machine, then compile it using g++ on a remote Linux machine.
11
+
You can use Visual Studio 2017 to edit, compile and build any C++ code base with full IntelliSense support without having to convert that code into a Visual Studio project or compile with the MSVC toolset. For example, you can edit a cross-platform CMake project in Visual Studio on a Windows machine, then compile it for Linux using g++ on a remote Linux machine.
12
12
13
13
## C++ compilation
14
14
15
15
To *build* a C++ program means to compile source code from one or more files and then link those files into an executable file (.exe), a dynamic-load library (.dll) or a static library (.lib).
16
16
17
-
Basic compilation involves three main steps:
17
+
Basic C++ compilation involves three main steps:
18
18
19
19
- The C++ preprocessor transforms all the #directives and macro definitions in each source file. This creates a *translation unit*.
20
-
- The C++ compiler compiles each translation unit into object files, according to whatever compiler options have been set.
21
-
- The *linker* merges the object files into a single executable according to the linker options that have been set.
20
+
- The C++ compiler compiles each translation unit into object files (.obj), applying whatever compiler options have been set.
21
+
- The *linker* merges the object files into a single executable, applying the linker options that have been set.
22
22
23
23
## The MSVC toolset
24
24
25
-
You can build simple programs by invoking the MSVC compiler (cl.exe) directly from the command line. The following example is taken from [](). The command accepts a single source code file, and builds an executable called *hello.exe*:
25
+
The Microsoft C++ compiler, linker, standard libraries, and related utilities comprise the MSCV compiler toolset (also called a toolchain or "build tools"). These are included in Visual Studio. You can also download and use the toolset as a standalone package for free from the [Build Tools for Visual Studio 2017 download location](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017).
26
+
27
+
You can build simple programs by invoking the MSVC compiler (cl.exe) directly from the command line. The following command accepts a single source code file, and invokes cl.exe to build an executable called *hello.exe*:
26
28
27
29
```cmd
28
30
cl /EHsc hello.cpp
29
31
```
30
-
Note that here the compiler (cl.exe) automatically invokes the C++ preprocessor and the linker to produce the final output file.
31
-
32
-
The MSVC compiler, linker, C++ standard libraries, and related utilities comprise the MSCV toolset. You can download and use the toolset as a standalone package for free from the [MSVC compiler tools download location](). For more information, see [Building on the command line](building-on-the-command-line.md).
32
+
Note that here the compiler (cl.exe) automatically invokes the C++ preprocessor and the linker to produce the final output file. For more information, see [Building on the command line](building-on-the-command-line.md).
33
33
34
34
## Build systems and projects
35
35
36
36
Most real-world programs use some kind of *build system* to manage complexities of compiling multiple source files for multiple configurations (i.e. debug vs. release), multiple platforms (x86, x64, ARM, and so on), custom build steps, and even multiple executables that must be compiled in a certain order. You make settings in a build configuration file(s), and the build system accepts that file as input before it invoke the compiler. The set of source code files and build configuration files needed to build an executable file is called a *project*.
37
37
38
38
The following list shows various options for building C++ projects in Visual Studio:
39
39
40
-
- create a Visual Studio project by using the Visual Studio IDE and configure it by using property pages. Visual Studio projects produce programs that run on Windows. For an overview, see [Compiling and Building](/visualstudio/ide/compiling-and-building-in-visual-studio).
40
+
- create a Visual Studio project by using the Visual Studio IDE and configure it by using property pages. Visual Studio projects produce programs that run on Windows. For an overview, see [Compiling and Building](/visualstudio/ide/compiling-and-building-in-visual-studio) in the Visual Studio documentation.
41
41
42
-
- open a folder that contains a CMakeLists.txt file. CMake support is integrated into Visual Studio. You can use the IDE to edit, test and debug without modifying the CMake files in any way. This enables you to work in the same CMake project as others who might be using different editors. CMake is the recommended approach for cross-platform development. For more information, see []().
42
+
- open a folder that contains a CMakeLists.txt file. CMake support is integrated into Visual Studio. You can use the IDE to edit, test and debug without modifying the CMake files in any way. This enables you to work in the same CMake project as others who might be using different editors. CMake is the recommended approach for cross-platform development. For more information, see [CMake projects](cmake-tools-for-visual-cpp.md).
43
43
44
-
- open a loose folder of source files with no project file. Visual Studio will use heuristics to build the files. This is an easy way to compile and run small console applications. For more information, see []().
44
+
- open a loose folder of source files with no project file. Visual Studio will use heuristics to build the files. This is an easy way to compile and run small console applications. For more information, see [Open Folder projects](non-msbuild-projects.md).
45
45
46
-
- open a folder that contains a makefile, or any other build system configuration file. You can configure Visual Studio to invoke any arbitrary build commands by adding JSON files to the folder. Or you can simply use the command line to build. For more information, see []().
46
+
- open a folder that contains a makefile, or any other build system configuration file. You can configure Visual Studio to invoke any arbitrary build commands by adding JSON files to the folder. For more information, see [Open Folder projects](non-msbuild-projects.md).
47
+
48
+
- Open a Windows makefile in Visual Studio. For more information, see [NMAKE Reference](reference/nmake-reference.md).
47
49
48
50
## MSBuild from the command line
49
51
@@ -60,9 +62,6 @@ How to code, build, and deploy CMake projects in Visual Studio.
60
62
[Open Folder projects](non-msbuild-projects.md)
61
63
How to use Visual Studio to code, build and deploy C++ projects based on any arbitrary build system, or no build system. at all.
0 commit comments