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
C++ projects often need to call functions or access data in a binary file such as static library (LIB files), DLL, Windows Runtime component, COM component, or .NET assembly. In these cases, you have to configure the project so that it can find that binary at build time. The specific steps depend on the type of your project, the type of the binary, and whether the binary gets built in the same solution as your project.
12
11
13
12
## Consuming libraries downloaded via vcpkg
14
13
15
-
To consume a library that you have downloaded by using the **vcpkg** package manager, you can ignore the instructions below. For more information, see [vcpkg.io](https://vcpkg.io/).
14
+
To consume a library that you have downloaded by using the **vcpkg** package manager, you can ignore the instructions below. For more information, see:
15
+
-[vcpkg in CMake projects](/vcpkg/users/buildsystems/cmake-integration)
16
+
-[Install and use packages with CMake in Visual Studio](/vcpkg/get_started/get-started-vs)
17
+
-[vcpkg in MSBuild projects](/vcpkg/users/buildsystems/msbuild-integration)
18
+
-[Tutorial: Install and use packages with MSBuild in Visual Studio](/vcpkg/get_started/get-started-msbuild)
Copy file name to clipboardExpand all lines: docs/build/cmake-projects-in-visual-studio.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,6 @@ title: "CMake projects in Visual Studio"
3
3
description: "How to create and build C++ projects using CMake in Visual Studio."
4
4
ms.date: 02/14/2022
5
5
helpviewer_keywords: ["CMake in Visual C++"]
6
-
ms.assetid: 444d50df-215e-4d31-933a-b41841f186f8
7
6
---
8
7
# CMake projects in Visual Studio
9
8
@@ -221,7 +220,10 @@ In Visual Studio 2019 version 16.9 and later, Visual Studio automatically config
221
220
222
221
## Vcpkg integration
223
222
224
-
CMake projects opened in Visual Studio integrate with vcpkg, a cross-platform C/C++ dependency manager. Before using vcpkg with Visual Studio, you must run `vcpkg integrate install`. For instructions and more information on vcpkg, see the [vcpkg documentation](https://vcpkg.io/).
223
+
CMake projects opened in Visual Studio integrate with vcpkg, a cross-platform C/C++ dependency manager. Before using vcpkg with Visual Studio, you must run `vcpkg integrate install`. For instructions and more information about vcpkg, see:
224
+
225
+
-[Install and use packages with CMake in Visual Studio](/vcpkg/get_started/get-started-vs)
226
+
-[vcpkg in CMake projects](/vcpkg/users/buildsystems/cmake-integration)
225
227
226
228
If *`CMakeSettings.json`* is your active configuration file, Visual Studio automatically passes the vcpkg toolchain file (`vcpkg.cmake`) to CMake. This behavior is disabled automatically when you specify any other toolchain in your CMake Settings configuration.
227
229
@@ -399,4 +401,6 @@ In Visual Studio 2015, Visual Studio users can use a [CMake generator](https://c
Copy file name to clipboardExpand all lines: docs/build/creating-and-managing-visual-cpp-projects.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,13 @@ Add source code files, icons, or any other items to your project by right-clicki
53
53
54
54
## Add third-party libraries to a project
55
55
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.
56
+
Over 900 C++ open source libraries are available via the [vcpkg](/vcpkg/) 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.
57
+
58
+
For more information about consuming a library that you have downloaded by using the **vcpkg** package manager, see:
59
+
-[vcpkg in CMake projects](/vcpkg/users/buildsystems/cmake-integration)
60
+
-[Install and use packages with CMake in Visual Studio](/vcpkg/get_started/get-started-vs)
61
+
-[vcpkg in MSBuild projects](/vcpkg/users/buildsystems/msbuild-integration)
62
+
-[Tutorial: Install and use packages with MSBuild in Visual Studio](/vcpkg/get_started/get-started-msbuild)
57
63
58
64
They're also commercial third-party libraries that you can install. Follow their installation instructions.
Copy file name to clipboardExpand all lines: docs/build/walkthrough-using-msbuild-to-create-a-visual-cpp-project.md
+5-13Lines changed: 5 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,19 +14,15 @@ This walkthrough demonstrates how to use MSBuild in a command prompt to build a
14
14
This walkthrough illustrates these tasks:
15
15
16
16
- Creating the C++ source files for your project.
17
-
18
17
- Creating the XML MSBuild project file.
19
-
20
18
- Using MSBuild to build your project.
21
-
22
19
- Using MSBuild to customize your project.
23
20
24
21
## Prerequisites
25
22
26
23
You need these prerequisites to complete this walkthrough:
27
24
28
25
- A copy of Visual Studio with the **Desktop development with C++** workload installed.
29
-
30
26
- A general understanding of the MSBuild system.
31
27
32
28
::: moniker range="msvc-140"
@@ -57,7 +53,6 @@ In this walkthrough, you'll create a project that has a source file and a header
57
53
### To create the C++ source files for your project
58
54
59
55
1. Create a folder for your project.
60
-
61
56
1. Create a file named *`main.cpp`* and add this code to the file:
62
57
63
58
```cpp
@@ -83,9 +78,7 @@ In this walkthrough, you'll create a project that has a source file and a header
83
78
An MSBuild project file is an XML file that contains a project root element (`<Project>`). In the example project you'll build, the `<Project>` element contains seven child elements:
84
79
85
80
- Three item group tags (`<ItemGroup>`) that specify project configuration and platform, source file name, and header file name.
86
-
87
81
- Three import tags (`<Import>`) that specify the location of Microsoft Visual C++ settings.
88
-
89
82
- A property group tag (`<PropertyGroup>`) that specifies project settings.
90
83
91
84
### To create the MSBuild project file
@@ -209,13 +202,9 @@ The application should display "Hello, from MSBuild!" in the console window.
209
202
MSBuild enables you to execute predefined build targets, apply user-defined properties, and use custom tools, events, and build steps. This section illustrates these tasks:
210
203
211
204
- Using MSBuild with build targets.
212
-
213
205
- Using MSBuild with build properties.
214
-
215
206
- Using MSBuild with the 64-bit compiler and tools.
216
-
217
207
- Using MSBuild with different toolsets.
218
-
219
208
- Adding MSBuild customizations.
220
209
221
210
### Using MSBuild with Build Targets
@@ -277,7 +266,10 @@ To rebuild your project with the Visual C++ 11.0 Windows XP toolset, enter this
277
266
MSBuild provides various ways to customize your build process. These articles show how to add custom build steps, tools, and events to your MSBuild project:
278
267
279
268
-[How to: Add a Custom Build Step to MSBuild Projects](how-to-add-a-custom-build-step-to-msbuild-projects.md)
280
-
281
269
-[How to: Add Custom Build Tools to MSBuild Projects](how-to-add-custom-build-tools-to-msbuild-projects.md)
282
-
283
270
-[How to: Use Build Events in MSBuild Projects](how-to-use-build-events-in-msbuild-projects.md)
271
+
272
+
## See also
273
+
274
+
-[vcpkg in MSBuild projects](/vcpkg/users/buildsystems/msbuild-integration)
275
+
-[Tutorial: Install and use packages with MSBuild in Visual Studio](/vcpkg/get_started/get-started-msbuild)
-[Secure your software supply chain | GitHub Security](https://github.com/features/security/software-supply-chain)
456
-
-[vcpkg | vcpkg.io](https://vcpkg.io/en/) - vcpkg private registries allow redirection of OSS acquisition to Enterprise-controlled resources for acquiring sources for a dependency, to minimize risk of upstream or over-the-wire attacks.
456
+
-[vcpkg](/vcpkg/) - vcpkg private registries allow redirection of OSS acquisition to Enterprise-controlled resources for acquiring sources for a dependency, to minimize risk of upstream or over-the-wire attacks.
Copy file name to clipboardExpand all lines: docs/code-quality/using-the-cpp-core-guidelines-checkers.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -299,7 +299,7 @@ Code Analysis requires a few environment variables and compiler command-line opt
299
299
300
300
## Use the Guideline Support Library
301
301
302
-
The Guideline Support Library (GSL) is designed to help you follow the Core Guidelines. The GSL includes definitions that let you replace error-prone constructs with safer alternatives. For example, you can replace a `T*, length` pair of parameters with the `span<T>` type. The GSL project is available on GitHub at [https://github.com/Microsoft/GSL](https://github.com/Microsoft/GSL). The library is open-source, so you can view the sources, make comments, or contribute. You can also use the [vcpkg](https://vcpkg.io/) package manager to download and install the library locally.
302
+
The Guideline Support Library (GSL) is designed to help you follow the Core Guidelines. The GSL includes definitions that let you replace error-prone constructs with safer alternatives. For example, you can replace a `T*, length` pair of parameters with the `span<T>` type. The GSL project is available on GitHub at [https://github.com/Microsoft/GSL](https://github.com/Microsoft/GSL). The library is open-source, so you can view the sources, make comments, or contribute. You can also use the [vcpkg](/vcpkg/) package manager to download and install the library locally.
Copy file name to clipboardExpand all lines: docs/error-messages/compiler-errors-1/fatal-error-c1083.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ then the file is not found. Use the correct path relative to the directory speci
56
56
57
57
## Third-party library issues and vcpkg
58
58
59
-
If you see this error when you are trying to configure a third-party library as part of your build, consider using [vcpkg](https://vcpkg.io/), a C++ package manager, to install and build the library. vcpkg supports a large and growing [list of third-party libraries](https://github.com/Microsoft/vcpkg/tree/master/ports), and sets all the configuration properties and dependencies required for successful builds as part of your project.
59
+
If you see this error when you are trying to configure a third-party library as part of your build, consider using [vcpkg](/vcpkg/), a C++ package manager, to install and build the library. vcpkg supports a large and growing [list of third-party libraries](https://github.com/Microsoft/vcpkg/tree/master/ports), and sets all the configuration properties and dependencies required for successful builds as part of your project.
60
60
61
61
## The file is in your project, but not the include search path
Copy file name to clipboardExpand all lines: docs/error-messages/tool-errors/linker-tools-error-lnk1104.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,9 +66,9 @@ There are several common causes for this issue:
66
66
67
67
To fix a path issue for command-line builds, verify the LIB environment variable is set. Make sure it includes paths for all the libraries you use, and for every configuration you build. In the IDE, the library paths get set by the **VC++ Directories** > **Library Directories** property. Make sure all the directories that contain the libraries you need are listed here, for every configuration you build.
68
68
69
-
You might need to supply a library directory that overrides a standard library directory. On the command line, use the [/LIBPATH](../../build/reference/libpath-additional-libpath.md) option. In the IDE, use the **Additional Library Directories** property in the **Configuration Properties > Linker > General** property page for your project.
69
+
You might need to supply a library directory that overrides a standard library directory. On the command line, use the [`/LIBPATH`](../../build/reference/libpath-additional-libpath.md) option. In the IDE, use the **Additional Library Directories** property in the **Configuration Properties > Linker > General** property page for your project.
70
70
71
-
Make sure you install every version of the library you need for the configurations you build. Consider using the [vcpkg](https://vcpkg.io/) package management utility to automate the installation and setup for many common libraries. When you can, it's best to build your own copies of third-party libraries. Then you're sure to have all the libraries' local dependencies, built for the same configurations as your project.
71
+
Make sure you install every version of the library you need for the configurations you build. Consider using the [vcpkg](/vcpkg/) package management utility to automate the installation and setup for many common libraries. When you can, it's best to build your own copies of third-party libraries. Then you're sure to have all the libraries' local dependencies, built for the same configurations as your project.
Copy file name to clipboardExpand all lines: docs/error-messages/tool-errors/linker-tools-error-lnk2019.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -94,7 +94,7 @@ A static library that was built using a version of Visual Studio before Visual S
94
94
95
95
## Third-party library issues and vcpkg
96
96
97
-
If you see this error when you're trying to configure a third-party library as part of your build, consider using [vcpkg](https://vcpkg.io/). **vcpkg** is a C++ package manager that uses your existing Visual Studio tools to install and build the library. **vcpkg** supports a large and growing [list of third-party libraries](https://github.com/Microsoft/vcpkg/tree/master/ports). It sets all the configuration properties and dependencies required for successful builds as part of your project.
97
+
If you see this error when you're trying to configure a third-party library as part of your build, consider using [vcpkg](/vcpkg/). **vcpkg** is a C++ package manager that uses your existing Visual Studio tools to install and build the library. **vcpkg** supports a large and growing [list of third-party libraries](https://github.com/Microsoft/vcpkg/tree/master/ports). It sets all the configuration properties and dependencies required for successful builds as part of your project.
0 commit comments