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
{{ message }}
Repository navigation
Commit 2b2c3fa
Browse filesBrowse the repository at this point in the historyBrowse files
Often, a C++ project needs 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 is being built in the same solution as your project.
11
+
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
12
13
13
## Consuming libraries downloaded via vcpkg
14
14
15
-
To consume a library that you have downloaded by using the **vcpkg** package manager, you can ignore the instructions below. See [vcpkg: A C++ package manager for Windows, Linux and MacOS](vcpkg.md#integrate-with-visual-studio-windows) for more information.
15
+
To consume a library that you have downloaded by using the **vcpkg** package manager, you can ignore the instructions below. See [vcpkg: A C++ package manager for Windows, Linux, and macOS](vcpkg.md) for more information.
16
16
17
17
## Consuming static libraries
18
18
19
-
If your static library project is being built in the same solution:
19
+
If your static library project gets built in the same solution:
20
20
21
-
1. #include the header file(s) for the static library using quotation marks. In a typical solution the path will start with `../<library project name>`. IntelliSense will help you find it.
21
+
1. #include the header file(s) for the static library using quotation marks. In a typical solution, the path starts with `../<library project name>`. IntelliSense will help you find it.
22
22
2. Add a reference to the static library project. Right-click on **References** under the application project node in **Solution Explorer** and choose **Add Reference**.
23
23
24
-
If the static library is not part of the solution:
24
+
If the static library isn't part of the solution:
25
25
26
26
1. Right-click on the application project node in **Solution Explorer** and then choose **Properties**.
27
-
2. In the **VC++ Directories** property page, add the path to the directory where the .lib file is located in **Library Paths** and add the path to the library header file(s) in**Include Directories**.
28
-
3. In the **Linker > Input** property page, add the name of the .lib file to **Additional Dependencies**.
27
+
2. In the **VC++ Directories** property page, add the path to the directory that contains the LIB file to **Library Paths**. Then, add the path to the library header file(s) to**Include Directories**.
28
+
3. In the **Linker > Input** property page, add the name of the LIB file to **Additional Dependencies**.
29
29
30
30
## Dynamic link libraries
31
31
32
-
If the DLL is being built as part of the same solution as the application, follow the same steps as for a static library.
32
+
If the DLL gets built as part of the same solution as the application, follow the same steps as for a static library.
33
33
34
-
If the DLL is not part of the application solution, you need the DLL file, the header(s) with prototypes for the exported functions and classes, and a .lib file that provides the necessary linking information.
34
+
If the DLL isn't part of the application solution, you need: the DLL file, the header(s) with prototypes for the exported functions and classes, and a LIB file that provides the necessary linking information.
35
35
36
36
1. Copy the DLL to the output folder of your project, or to another folder in the standard Windows search path for DLLs. See [Dynamic-Link Library Search Order](/windows/win32/dlls/dynamic-link-library-search-order).
37
-
2. Follow steps 1-3 for static libraries to provide the paths to the headers and .lib file.
37
+
2. Follow steps 1-3 for static libraries to provide the paths to the headers and LIB file.
38
38
39
39
## COM objects
40
40
41
-
If your native C++ application needs to consume a COM object, and that object is *registered*, then all you have to do is call CoCreateInstance and pass in the CLSID of the object. The system will find it in the Windows Registry and load it. A C++/CLI project can consume a COM object in the same way, or by adding a reference to it from the **Add References > COM** list and consuming it through its [Runtime callable wrapper](/dotnet/framework/interop/runtime-callable-wrapper).
41
+
If your native C++ application needs to consume a COM object, and that object is *registered*, then all you have to do is call CoCreateInstance and pass in the CLSID of the object. The system will find it in the Windows Registry and load it. A C++/CLI project can consume a COM object in the same way. Or, it can consume it by adding a reference to it from the **Add References > COM** list and consuming it through its [Runtime callable wrapper](/dotnet/framework/interop/runtime-callable-wrapper).
42
42
43
43
## .NET assemblies and Windows Runtime Components
44
44
45
-
In UWP or C++/CLI projects, you consume .NET assemblies or Windows Runtime Components by adding a *reference* to the assembly or component. Under the **References** node in a UWP or C++/CLI project, you see references to commonly-used components. Right-click on the **References** node in **Solution Explorer** to bring up the **Reference Manager** and browse through additional components that are known to the system. Click the **Browse** button to navigate to any folder where a custom component is located. Because .NET assemblies and Windows Runtime components contain built-in type information, you can view their methods and classes by right-clicking and choosing **View in Object Browser**.
45
+
In UWP or C++/CLI projects, you consume .NET assemblies or Windows Runtime Components by adding a *reference* to the assembly or component. Under the **References** node in a UWP or C++/CLI project, you see references to commonlyused components. Right-click on the **References** node in **Solution Explorer** to bring up the **Reference Manager** and browse through the components available on the system. Choose the **Browse** button to navigate to any folder that contains a custom component. Because .NET assemblies and Windows Runtime components contain built-in type information, you can view their methods and classes by right-clicking and choosing **View in Object Browser**.
46
46
47
47
## Reference properties
48
48
49
-
Each kind of reference has properties. You can view the properties by selecting the reference in Solution Explorer and pressing **Alt + Enter**, or else right-clicking and choosing **Properties**. Some properties are read-only and some can be modified. However, typically you don't have to manually modify these properties.
49
+
Each kind of reference has properties. You can view the properties by selecting the reference in Solution Explorer and pressing **Alt + Enter**, or else right-clicking and choosing **Properties**. Some properties are read-only and some are modifiable. However, typically you don't have to manually modify these properties.
50
50
51
51
### ActiveX reference properties
52
52
53
-
ActiveX reference properties are available only for references to COM components. These properties are displayed only when a COM component is selected in the **References** pane. The properties cannot be modified.
53
+
ActiveX reference properties are available only for references to COM components. These properties get displayed only when you select a COM component in the **References** pane. The properties aren't modifiable.
54
54
55
55
-**Control Full Path**
56
56
@@ -70,11 +70,11 @@ ActiveX reference properties are available only for references to COM components
70
70
71
71
-**Wrapper Tool**
72
72
73
-
Displays the tool that is used to build the interop assembly from the referenced COM library or ActiveX control.
73
+
Displays the tool that's used to build the interop assembly from the referenced COM library or ActiveX control.
74
74
75
75
### Assembly reference properties (C++/CLI)
76
76
77
-
Assembly reference properties are available only for references to .NET Framework assemblies in C++/CLI projects. These properties are displayed only when a .NET Framework assembly is selected in the **References** pane. The properties cannot be modified.
77
+
Assembly reference properties are available only for references to .NET Framework assemblies in C++/CLI projects. These properties get displayed only when you select a .NET Framework assembly in the **References** pane. The properties aren't modifiable.
78
78
79
79
-**Relative Path**
80
80
@@ -94,27 +94,27 @@ The following properties are available on various kinds of references. They enab
94
94
95
95
-**Reference Assembly Output**
96
96
97
-
Specifies that this assembly is used in the build process. If **`true`**, the assembly is used on the compiler command line during the build.
97
+
Specifies that this assembly gets used in the build process. If **`true`**, the assembly gets used on the compiler command line during the build.
98
98
99
99
### Project-to-project reference properties
100
100
101
-
The following properties define a *project-to-project reference* from the project that is selected in the **References** pane to another project in the same solution. For more information, see [Managing references in a project](/visualstudio/ide/managing-references-in-a-project).
101
+
The following properties define a *project-to-project reference* from the project that's selected in the **References** pane to another project in the same solution. For more information, see [Managing references in a project](/visualstudio/ide/managing-references-in-a-project).
102
102
103
103
-**Link Library Dependencies**
104
104
105
-
When this property is **True**, the project system links into the dependent project the .lib files that are produced by the independent project. Typically, you will specify **True**.
105
+
When this property is **True**, the project system links the LIB files that the independent project produces into the dependent project. Typically, you'll specify **True**.
106
106
107
107
-**Project Identifier**
108
108
109
-
Uniquely identifies the independent project. The property value is an internal system GUID that cannot be modified.
109
+
Uniquely identifies the independent project. The property value is an internal system GUID that isn't modifiable.
110
110
111
111
-**Use Library Dependency Inputs**
112
112
113
-
When this property is **False**, the project system will not link into the dependent project the .obj files for the library produced by the independent project. Consequently, this value disables incremental linking. Typically, you will specify **False** because building the application can take a long time if there are many independent projects.
113
+
When this property is **False**, the project system won't link the OBJ files for the library that the independent project produces into the dependent project. That's why this value disables incremental linking. Typically, you'll specify **False** because building the application can take a long time if there are many independent projects.
114
114
115
115
### Read-only reference properties (COM & .NET)
116
116
117
-
The following properties are found on COM and .NET assembly references, and cannot be modified.
117
+
The following properties exist on COM and .NET assembly references, and aren't modifiable.
118
118
119
119
-**Assembly Name**
120
120
@@ -134,7 +134,7 @@ The following properties are found on COM and .NET assembly references, and cann
134
134
135
135
-**Identity**
136
136
137
-
For the .NET Frameworkassemblies, displays the full path. For COM components, displays the GUID.
137
+
For the .NET Framework assemblies, displays the full path. For COM components, displays the GUID.
138
138
139
139
-**Label**
140
140
@@ -146,11 +146,11 @@ The following properties are found on COM and .NET assembly references, and cann
146
146
147
147
-**Public Key Token**
148
148
149
-
Displays the public key token that is used to identify the referenced assembly.
149
+
Displays the public key token used to identify the referenced assembly.
150
150
151
151
-**Strong Name**
152
152
153
-
**`true`** if the referenced assembly has a strong name. A strong named assembly is uniquely versioned.
153
+
**`true`** if the referenced assembly has a strong name. A strong named assembly has a unique version.
title: "Install vcpkg on Windows, Linux, and macOS"
3
+
description: "Learn how to install and update vcpkg on Windows, macOS, and Linux."
4
+
ms.date: 12/17/2020
5
+
ms.topic: "reference"
6
+
ms.technology: "cpp-ide"
7
+
---
8
+
# Install vcpkg on Windows, Linux, and macOS
9
+
10
+
You install vcpkg by making a local clone (copy) from the vcpkg GitHub repo.
11
+
12
+
## Install vcpkg
13
+
14
+
Choose your platform for specific instructions:
15
+
16
+
### [Linux](#tab/linux)
17
+
18
+
Prerequisites for Linux:
19
+
20
+
-[Git](https://git-scm.com/downloads)
21
+
- g++ version 6 or greater
22
+
23
+
#### To install Linux development tools
24
+
25
+
Different Linux distros may require you install different packages. Follow these instructions on Debian, Ubuntu, popOS, and other Debian-based distributions:
26
+
27
+
1. In a shell window, run this command:
28
+
29
+
**`sudo apt-get update`**
30
+
31
+
1. When the update completes, run this command:
32
+
33
+
**`sudo apt-get install build-essential tar curl zip unzip`**
34
+
35
+
Follow these instructions on CentOS:
36
+
37
+
1. In a shell window, run this command:
38
+
39
+
**`sudo yum install centos-release-scl`**
40
+
41
+
1. Next, install and enable the development tools by running these commands:
42
+
43
+
**`sudo yum install devtoolset-7`**
44
+
45
+
**`scl enable devtoolset-7 bash`**
46
+
47
+
For any other distributions, make sure you're installing g++ 6 or above.
48
+
49
+
#### To copy and set up vcpkg on Linux
50
+
51
+
1. In a shell window, create a directory for your cloned instance of vcpkg. If you plan to install libraries for different build targets, it's a good idea to include the target in the directory name. We recommend short path names without spaces, like *`./x64`* or *`./iot`*, since otherwise you may run into path issues for some port build systems. In the shell window, change to the directory you just made.
52
+
53
+
1. Clone the vcpkg repo from GitHub: [https://github.com/Microsoft/vcpkg](https://github.com/Microsoft/vcpkg).
This command creates a local copy of the repo in a *`vcpkg`* subdirectory. This location is the vcpkg *root directory* for this clone of vcpkg.
58
+
59
+
1. Next, change to the vcpkg root directory, and run the vcpkg bootstrapper command:
60
+
61
+
> **`./bootstrap-vcpkg.sh`**
62
+
63
+
The bootstrapper configures vcpkg with the locations of the compiler, tools, and standard libraries.
64
+
65
+
### [macOS](#tab/macos)
66
+
67
+
Prerequisites for macOS:
68
+
69
+
- macOS developer tools
70
+
- On macOS 10.14 or below, you will also need:
71
+
- Homebrew
72
+
- g++ version 6 or greater
73
+
74
+
#### To install macOS developer tools
75
+
76
+
1. On macOS 10.15, run this command in Terminal:
77
+
78
+
**`xcode-select --install`**
79
+
80
+
Then follow along with the prompts in the windows that comes up.
81
+
82
+
On macOS 10.14 and previous, you'll also need to install g++ from homebrew. This procedure is only necessary if you're using a macOS version before 10.15.
83
+
84
+
#### To install GCC for macOS before 10.15
85
+
86
+
1. To install Homebrew, open Terminal, and then run the following command:
1. To install an up-to-date version of gcc, run this command in Terminal:
91
+
92
+
**`brew install gcc`**
93
+
94
+
#### To copy and set up vcpkg on macOS
95
+
96
+
1. In Terminal, create a directory for your cloned instance of vcpkg. If you plan to install libraries for different build targets, it's a good idea to include the target in the directory name. We recommend short path names without spaces, like *`./macos`* or *`./iot`*, since otherwise you may run into path issues for some port build systems. In Terminal, change to the directory you just made.
97
+
98
+
1. Clone the vcpkg repo from GitHub: [https://github.com/Microsoft/vcpkg](https://github.com/Microsoft/vcpkg).
This command creates a local copy of the repo in a *`vcpkg`* subdirectory. This location is the vcpkg *root directory* for this clone of vcpkg.
103
+
104
+
1. Next, change to the vcpkg root directory, and run the vcpkg bootstrapper command:
105
+
106
+
> **`./bootstrap-vcpkg.sh`**
107
+
108
+
The bootstrapper configures vcpkg with the locations of the compiler, tools, and standard libraries.
109
+
110
+
### [Windows](#tab/windows)
111
+
112
+
Prerequisites:
113
+
114
+
- Windows 7 or newer
115
+
-[Git for Windows](https://git-scm.com/downloads)
116
+
-[Visual Studio](https://visualstudio.microsoft.com/) 2015 Update 3 or greater with the English language pack
117
+
118
+
#### To copy and set up vcpkg on Windows
119
+
120
+
1. In a Command Prompt window, create a directory for your cloned instance of vcpkg. If you plan to install libraries for different build targets, it's a good idea to include the target in the directory name. We recommend short path names without spaces, like *`C:\src\win32\`* or *`C:\dev\iot\`*, since otherwise you may run into path issues for some port build systems. In the command window, change to the directory you just made.
121
+
122
+
1. Clone the vcpkg repo from GitHub: [https://github.com/Microsoft/vcpkg](https://github.com/Microsoft/vcpkg).
This command creates a local copy of the repo in a *`vcpkg`* subdirectory. This location is the vcpkg *root directory* for this clone of vcpkg.
127
+
128
+
1. Once the download is complete, change to the *`vcpkg`* directory in your command prompt window.
129
+
130
+
1. In the vcpkg root directory, run the vcpkg bootstrapper command:
131
+
132
+
> **`bootstrap-vcpkg.bat`**
133
+
134
+
The bootstrapper configures vcpkg with the locations of the Microsoft C/C++ tools, libraries, and the Windows SDK.
135
+
136
+
---
137
+
138
+
Once vcpkg is set up, you're ready to install libraries. For more information, see [Manage libraries with vcpkg](manage-libraries-with-vcpkg.md). vcpkg can also be integrated with Visual Studio on Windows, or with Visual Studio Code on any platform. For more information, see [Integrate vcpkg](integrate-vcpkg.md).
139
+
140
+
## Update vcpkg
141
+
142
+
The vcpkg package manager is updated regularly on GitHub. To update your clone of vcpkg to the latest version, from the vcpkg root directory, run **`git pull`**. This command syncs your copy of vcpkg with the version on GitHub. After download is complete, run the bootstrapper again. The bootstrapper rebuilds the vcpkg program, but leaves your installed libraries in place.
143
+
144
+
## Uninstall vcpkg
145
+
146
+
To uninstall vcpkg, just delete the *`vcpkg`* directory. Deleting this directory uninstalls the vcpkg distribution, and all the libraries that vcpkg has installed.
147
+
148
+
However if you have executed **`vcpkg integrate install`** you should execute **`vcpkg integrate remove`** to ensure the integration is cleaned, before the folder is removed. For more information, see [Integrate vcpkg](integrate-vcpkg.md).
149
+
150
+
## See also
151
+
152
+
[vcpkg: a C++ package manager for Windows, Linux, and macOS](./vcpkg.md)\
153
+
[vcpkg on GitHub](https://github.com/Microsoft/vcpkg)\
154
+
[Integrate vcpkg](integrate-vcpkg.md)\
155
+
[Manage libraries with vcpkg](manage-libraries-with-vcpkg.md)\
0 commit comments