Announcing a single C++ library manager for Linux, macOS and Windows: Vcpkg

At Microsoft, the core of our vision is “Any Developer, Any App, Any Platform” and we are committed to bringing you the most productive development tools and services to build your apps across all platforms. With this in mind, we are thrilled to announce today the availability of vcpkg on Linux and MacOS. This gives you immediate access to the vcpkg catalog of C++ libraries on two new platforms, with the same simple steps you are familiar with on Windows and UWP today.

Vcpkg has come a long way since its launch at CppCon 2016. Starting from only 20 libraries, we have seen an incredible growth in the last 19 months with over 900 libraries and features now available. All credit goes to the invaluable contributions from our amazing community.

In the feedback you gave us so far, Linux and Mac support was the most requested feature by far. So we are excited today to see vcpkg reach an even wider community and facilitate cross-platform access to more C++ libraries. We invite you today to try vcpkg whether you target Windows, Linux or MacOS.

To learn more about using vcpkg on Windows, read our previous post on how to get started with vcpkg on Windows.

Using vcpkg on Linux and Mac

The Vcpkg tool is now compatible with Linux, Mac and other POSIX systems. This was made possible only through the contributions of several fantastic community members

At the time of writing this blogpost, over 350 libraries are available for Linux and Mac and we expect that number to grow quickly. We currently test daily on Ubuntu-LTS 16.04/18.04 and we had success on Arch, Fedora, FreeBSD.

 

Getting started:

1)      Clone the vcpkg repo: git clone https://github.com/Microsoft/vcpkg

2)      Bootstrap vcpkg: ./bootstrap-vcpkg.sh

3)      Once vcpkg is built, you can build any library using the following syntax:

          vcpkg install sdl2

This will install sdl2:x64-linux (x64 static is the default and only option available on Linux)

The result (.h, .lib) is stored in the same folder tree, reference this folder in your build system configuration.

 

4)      Using the generated library

  1. If you use CMake as build system, then you should use CMAKE_TOOLCHAIN_FILE to make libraries available with `find_package()`. E.g.: cmake .. “-DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake”

 

  1. You should reference the vcpkg folder containing the headers (\vcpkg\installed\x64-linux\include) and also the one containing the .lib (\vcpkg\installed\x64-linux\lib) to be able to build your project using the generated libraries.

Using vcpkg to target Linux from Windows via WSL

As WSL is a Linux system, we’ll use WSL as we did with Linux. Once configured correctly you will be able to produce Linux binaries from your Windows machine as if they had been generated from a Linux box. Follow the same instruction as for installing on Linux. See how to  Setup WSL on Windows 10, and configure it with the Visual Studio extension for Linux.

As shown in the screenshot above, the vcpkg directory could be shared between Windows and WSL. In this example sdl2 and sqlite3 were built from WSL (binaries for Linux); sqlite3 was built also for Windows (Windows dll).

In closing

Install vcpkg on Linux or Mac and try it in your cross-platform projects and let us know how we can make it better and what is your cross-platform usage scenario.

As always, your feedback and comments really matter to us, open an issue on GitHub or reach out to us at vcpkg@microsoft.com for any comments and suggestions., complettaking a moment to complete oure surveys