ScriptsMay 3, 2026·3 min read

vcpkg — Cross-Platform C/C++ Package Manager by Microsoft

vcpkg is an open-source C/C++ package manager from Microsoft that simplifies acquiring and building over 2,000 libraries across Windows, macOS, and Linux with a single consistent workflow.

Introduction

Managing C and C++ dependencies has historically been painful, with each OS and build system requiring its own approach. vcpkg solves this by providing a unified, cross-platform package manager that integrates directly with CMake and MSBuild, letting developers install libraries with a single command.

What vcpkg Does

  • Installs and manages C/C++ libraries from a catalog of over 2,000 open-source packages
  • Supports Windows, macOS, and Linux with consistent behavior across all platforms
  • Integrates with CMake and MSBuild so installed libraries are automatically discoverable
  • Provides manifest mode (vcpkg.json) for declarative, reproducible dependency management
  • Supports custom triplets to cross-compile for different architectures and configurations

Architecture Overview

vcpkg uses portfiles (CMake scripts) that describe how to download, patch, build, and install each library. When you request a package, vcpkg resolves its dependency tree, downloads sources, builds them using the appropriate toolchain for your target triplet, and places headers and binaries in a structured install tree. In manifest mode, a vcpkg.json file in your project root declares dependencies, and vcpkg resolves them automatically during the CMake configure step. Binary caching lets teams share prebuilt packages via NuGet feeds, GitHub Actions caches, or filesystem paths.

Self-Hosting & Configuration

  • Clone the repo and run bootstrap-vcpkg.sh (Linux/macOS) or bootstrap-vcpkg.bat (Windows)
  • Use manifest mode by adding a vcpkg.json to your project root with required dependencies
  • Set CMAKE_TOOLCHAIN_FILE to vcpkg's toolchain file for seamless CMake integration
  • Configure binary caching with VCPKG_BINARY_SOURCES to speed up CI builds
  • Create custom triplets for specialized build configurations or cross-compilation targets

Key Features

  • Works identically on Windows, macOS, and Linux without platform-specific workarounds
  • Manifest mode locks dependency versions for reproducible builds across teams
  • Binary caching dramatically reduces CI build times by reusing prebuilt packages
  • Overlay ports let you patch or replace any library without forking the main registry
  • Versioning support with baseline pinning ensures consistent dependency resolution

Comparison with Similar Tools

  • Conan — More mature registry with prebuilt binaries for many configurations; vcpkg offers tighter CMake integration and simpler onboarding
  • Hunter — CMake-only package manager; less actively maintained and smaller package catalog
  • build2 — Integrated build system and package manager; steeper learning curve but more cohesive design
  • pkg-config — System-level library discovery only; no dependency resolution or cross-platform builds
  • apt/brew — OS package managers install system-wide; vcpkg provides per-project isolation

FAQ

Q: Does vcpkg require Visual Studio on Windows? A: No. vcpkg works with any MSVC, Clang, or GCC toolchain. Visual Studio is optional.

Q: Can I use vcpkg in CI pipelines? A: Yes. Manifest mode plus binary caching is designed for CI. Most major CI platforms are supported out of the box.

Q: How do I add a library that is not in the vcpkg registry? A: Create a custom overlay port with a portfile.cmake and vcpkg.json describing the build steps, then point vcpkg to your overlay directory.

Q: Does vcpkg support C projects or only C++? A: vcpkg supports both C and C++ libraries. The package catalog includes many pure-C projects.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets