Learn C++
#include "tooling/packages.hpp"

Package Managers (vcpkg & Conan) in C++

//concept

C++ long lacked a standard package manager, and two tools filled the gap: vcpkg (Microsoft, source-or-binary builds integrated with CMake) and Conan (decentralized, binary Caching, any build system). Both resolve named dependencies to exact versions, fetch and build them, and expose them to your build β€” vcpkg via toolchain file, Conan via generated CMake integration.

The workflow converges: declare dependencies (vcpkg.json manifest or conanfile.txt), install into the project, find_package in CMakeLists, link. Manifest mode pins versions per project, ending dependency drift between machines and CI.

//how it works
1

Declare in a manifest

vcpkg.json lists {"dependencies": ["fmt", "zlib"]}; conanfile.txt lists [requires] fmt/10.0 β€” versions pinned per project.

2

Install into the project

The manager fetches sources, builds for your triplet/profile, and caches binaries for reuse across projects.

3

Consume from CMake

find_package(fmt CONFIG REQUIRED) plus target_link_libraries(app PRIVATE fmt::fmt) β€” the standard two lines per dependency.

4

vcpkg vs Conan

vcpkg: CMake-native, simplest for CMake shops. Conan: build-system-agnostic with stronger binary story. Either beats vendoring.

//example
// vcpkg.json
// { "dependencies": [ "fmt" ] }
// CMakeLists.txt:
// find_package(fmt CONFIG REQUIRED)
// target_link_libraries(app PRIVATE fmt::fmt)
#include <iostream>
#include <fmt/core.h>
int main() {
std::cout << fmt::format("v{}", 10) << std::endl;
return 0;
}
Output
v10
1The manifest declares fmt; the manager builds it once and remembers how.
2find_package locates the built fmt config; linking fmt::fmt wires headers and binaries to the app.
3The program formats through the third-party library and prints v10 β€” dependency to output in four declarations.
//use cases
Adding JSON, formatting, or HTTP libraries without vendoring sources
Reproducible CI builds with per-project pinned manifests
Sharing prebuilt binaries across a team via Conan remotes
Migrating vendored third-party trees to managed dependencies

Recommended resourcesAffiliate links Β· may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice β€” pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from β€” great next to the visualizers.See the books

Practice what you learned

Re-implement each visualized algorithm in C++ yourself β€” building beats watching.