Skip to content

Commit 7a204e8

Browse files
author
PRMerger8
authored
Merge pull request MicrosoftDocs#812 from mikeblome/mb-vcpkg2
Updates for cross-platform support
2 parents f69e13d + 5057104 commit 7a204e8

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

docs/vcpkg.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
---
2-
title: vcpkg-- a C++ Package Manager for Windows| Microsoft Docs
2+
title: vcpkg-- A C++ package manager for Windows, Linux and MacOS | Microsoft Docs
33
description: vcpkg is a command line package manager that greatly simplifies the acquisition and installation of open-source C++ libraries on Windows.
44
keywords: vcpkg
55
author: mikeblome
66
ms.author: mblome
7-
ms.date: 04/06/2018
7+
ms.date: 05/14/2018
88
ms.technology: ["cpp-ide"]
99
ms.tgt_pltfrm: "windows"
1010
ms.assetid: f50d459a-e18f-4b4e-814b-913e444cedd6
1111
ms.topic: "conceptual"
1212
dev_langs: ["C++"]
1313
ms.workload: ["cplusplus"]
1414
---
15-
# vcpkg: C++ Package Manager for Windows
15+
# vcpkg: A C++ package manager for Windows, Linux and MacOS
1616

17-
vcpkg is a command-line package manager that greatly simplifies the acquisition and installation of third-party libraries on Windows. If your project uses third-party libraries, we recommend that you use vcpkg to install them. vcpkg supports both open-source and proprietary libraries. All libraries in the vcpkg public catalog have been tested for compatibility with Visual Studio 2015 and Visual Studio 2017. As of January 2018 there are over 600 libraries in the catalog and the C++ community is adding more libraries on an ongoing basis.
17+
vcpkg is a command-line package manager that greatly simplifies the acquisition and installation of third-party libraries on Windows, Linux and MacOS. If your project uses third-party libraries, we recommend that you use vcpkg to install them. vcpkg supports both open-source and proprietary libraries. All libraries in the vcpkg Windows catalog have been tested for compatibility with Visual Studio 2015 and Visual Studio 2017. As of May 2018 there are over 900 libraries in the Windows catalog and over 350 in the Linux/MacOS catalog. The C++ community is adding more libraries to both catalogs on an ongoing basis.
1818

1919
## Simple yet flexible
2020

2121
With a single command, you can download sources and build a library. vcpkg is itself an open-source project, available on GitHub. You can customize your private clone(s) in any way you like. For example, you can specify different libraries, or different versions of libraries than what are found in the public catalog. You can have multiple clones of vcpkg on a single machine, each one producing custom sets of libraries and/or compilation switches, etc. Each clone is a self-contained, x-copyable environment with its own copy of vcpkg.exe that operates only on its own hierarchy. vcpkg is not added to any environment variables, and has no dependency on the Windows Registry or Visual Studio.
2222

2323
## Sources not binaries
2424

25-
For libraries in the public catalog, vcpkg downloads sources instead of binaries[1]. It compiles those sources using Visual Studio 2017, or Visual Studio 2015 if 2017 is not installed. In C++, it is very important that any libraries you use are complied with the same compiler, and compiler version, as the application code that links to it. By using vcpkg, you eliminate or at least greatly reduce the potential for mismatched binaries and the problems they can cause. In teams that are standardized on a specific version of the Visual C++ compiler, one team member can use vcpkg to download sources and compile a set of binaries and then use the export command to zip up the binaries and headers for other team members. For more information, see Export compiled binaries and headers below.
25+
For libraries in the Windows catalog, vcpkg downloads sources instead of binaries[1]. It compiles those sources using Visual Studio 2017, or Visual Studio 2015 if 2017 is not installed. In C++, it is very important that any libraries you use are complied with the same compiler, and compiler version, as the application code that links to it. By using vcpkg, you eliminate or at least greatly reduce the potential for mismatched binaries and the problems they can cause. In teams that are standardized on a specific version of the Visual C++ compiler, one team member can use vcpkg to download sources and compile a set of binaries and then use the export command to zip up the binaries and headers for other team members. For more information, see [Export compiled binaries and headers](#export_binaries_per_project) below.
2626

2727
If you create a vcpkg clone with private libraries in the ports collection, you can add a port that downloads prebuilt binaries and headers and write a portfile.cmake file that simply copies those files to the desired location.
2828

2929
[1] *Note: for some proprietary libraries, sources are not available. Vcpkg will download compatible prebuilt binaries in these cases.*
3030

31-
## Installation
31+
## Installation
3232

3333
Clone the vcpkg repo from GitHub: https://github.com/Microsoft/vcpkg. You can download to any folder location you prefer.
3434

35-
Run the bootstrapper in the root folder: **bootstrap-vcpkg.bat**.
35+
Run the bootstrapper in the root folder:
36+
- **bootstrap-vcpkg.bat** (Windows)
37+
- ./bootstrap-vcpkg.sh (Linux, MacOS)
3638

3739
## Basic tasks
3840

@@ -64,7 +66,11 @@ taglib 1.11.1-2 TagLib Audio Meta-Data Library
6466

6567
### Install a library on your local machine
6668

67-
After you get the name of a library by using **vcpkg search**, you use **vcpkg install** to download the library and compile it. vcpkg uses the library's portfile in the ports directory. If no triplet is specified, vcpkg will install and compile for x86-windows. If the portfile specifies dependencies, vcpkg downloads and installs those also. After downloading, vcpkg builds the library by using whatever build system the library uses. CMake and MSBuild projects files are preferred, but MAKE is supported along with any other build system. If vcpkg cannot find the specified build system on the local machine, it downloads and installs it.
69+
After you get the name of a library by using **vcpkg search**, you use **vcpkg install** to download the library and compile it. vcpkg uses the library's portfile in the ports directory. If no triplet is specified, vcpkg will install and compile for the default triplet for the target platform: x86-windows, x64-linux.cmake, or x64-osx.cmake.
70+
71+
For Linux libraries, vcpkg depends on gcc being installed on the local machine. On MacOS, vcpkg uses Clang.
72+
73+
If the portfile specifies dependencies, vcpkg downloads and installs those also. After downloading, vcpkg builds the library by using whatever build system the library uses. CMake and (on Windows) MSBuild projects are preferred, but MAKE is supported along with any other build system. If vcpkg cannot find the specified build system on the local machine, it downloads and installs it.
6874

6975
```cmd
7076
> vcpkg install boost:x86-windows
@@ -74,6 +80,14 @@ The following packages will be built and installed:
7480
* bzip2:x86-windows
7581
* zlib:x86-windows
7682
Additional packages (*) will be installed to complete this operation.
83+
84+
```
85+
86+
For CMAKE projects, use use CMAKE_TOOLCHAIN_FILE to make libraries available with `find_package()`. For example:
87+
88+
```cmd
89+
cmake .. -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake (Linux/MacOS)
90+
cmake .. -DCMAKE_TOOLCHAIN_FILE=vcpkg\scripts\buildsystems\vcpkg.cmake (Windows)
7791
```
7892

7993
## List the libraries already installed
@@ -91,7 +105,7 @@ websocketpp:x86-windows 0.7.0 Library that implements RFC6455 The WebSocket P
91105
zlib:x86-windows 1.2.11 A compression library
92106
```
93107

94-
## Integrate with Visual Studio
108+
## Integrate with Visual Studio (Windows)
95109

96110
### Per-user
97111

@@ -110,7 +124,12 @@ If you need to use a specific version of a library that is different from the ve
110124
1. Run **vcpkg install \<library>**.
111125
1. Use **vcpkg integrate project** to create a NuGet package that references that library on a per-project basis.
112126

113-
## Export compiled binaries and headers
127+
## Target Linux from Windows via WSL
128+
129+
You can produce Linux binaries from a Windows machine by using the Windows Subsystem for Linux (WSL). Follow the instructions to [Set up WSL on Windows 10](https://docs.microsoft.com/en-us/windows/wsl/install-win10), and configure it with the [Visual Studio extension for Linux](https://blogs.msdn.microsoft.com/vcblog/2017/02/08/targeting-windows-subsystem-for-linux-from-visual-studio/). You can put all your built libraries for both Windows and Linux into the same folder and access it from both Windows and WSL.
130+
131+
132+
## <a name="export_binaries_per_project"></a> Export compiled binaries and headers
114133

115134
Requiring everyone on a team to download and build libraries can be inefficient. A single team member can do that work, and then use **vcpkg export** to create a zip file of the binaries and headers that can be easily shared with other team members.
116135

@@ -233,7 +252,6 @@ The contents of a vcpkg instance are:
233252
|**vcpkg integrate project**|Generate a referencing NuGet package for individual VS project use|
234253
|**vcpkg export \<pkg>... [opt]...**|Export a package|
235254
|**vcpkg edit \<pkg>**|Open up a port for editing (uses %EDITOR%, default 'code')|
236-
|**vcpkg import \<pkg>**|Import a pre-built library|
237255
|**vcpkg create \<pkg> \<url> [archivename]**|Create a new package|
238256
|**vcpkg owns \<pat>**|Search for files in installed packages|
239257
|**vcpkg cache**|List cached compiled packages|

0 commit comments

Comments
 (0)