A lean, modern C++23 take on core libp2p building blocks with a small, focused example. It uses Boost.Asio coroutines, DI via Boost.DI, QUIC transport via lsquic, logging via soralog, and crypto (secp256k1, OpenSSL), all managed through vcpkg. It also provides C bindings (libp2p_c) so you can use it from C and other languages like Zig; see example/01-echo for C and Zig samples.
- C++23, header-first public API in
include/libp2p/** - Basic host, protocol plumbing, and an Echo protocol example
- QUIC transport (lsquic) + Boost.Asio
- Dependency Injection with Boost.DI
- Logging with soralog
- Packaged with vcpkg manifests and CMake Presets
- macOS or Linux with a C++23 compiler (AppleClang 15+/Clang 16+/GCC 12+)
- CMake 3.25+ and Ninja
- Git
- vcpkg (see next section for install and setup)
Tip (macOS): install tools via Homebrew: brew install cmake ninja git
This project uses vcpkg in manifest mode via the CMake toolchain. You don’t need to "integrate" globally, but you must have vcpkg cloned and bootstrapped, and VCPKG_ROOT set.
- Clone and bootstrap
git clone https://github.com/microsoft/vcpkg.git "$HOME/vcpkg"
"$HOME/vcpkg"/bootstrap-vcpkg.sh- Set VCPKG_ROOT (zsh)
Add to your shell profile so it’s available in every terminal:
echo 'export VCPKG_ROOT="$HOME/vcpkg"' >> ~/.zprofile
# if you use ~/.zshrc instead, write there and reload the shell
export VCPKG_ROOT="$HOME/vcpkg"- Verify
"$VCPKG_ROOT"/vcpkg versionThis project is CMake + vcpkg manifest-based. The provided preset uses Ninja and the vcpkg toolchain.
First configure (will auto-install deps on first run):
cmake --preset defaultThen build:
cmake --build build -jNotes
- The preset builds Debug by default (see
CMakePresets.json). - To build Release without creating a new preset:
cmake -S . -B build-release -G Ninja \ -D CMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \ -D CMAKE_BUILD_TYPE=Release cmake --build build-release -j
See example/01-echo/README.md for usage and run instructions.
include/libp2p/**— public headerssrc/**— library implementationexample/01-echo/**— Echo server and clientvcpkg.json,vcpkg-configuration.json— dependencies and registriescmake/**— helper CMake scripts
- vcpkg not found: ensure
VCPKG_ROOTis set and points to your vcpkg clone (and that your shell exports it). - First configure is slow: vcpkg will build/install dependencies; subsequent builds are fast.
- Linking errors on macOS: ensure you’re using the same toolchain/SDK across configure and build, and that you didn’t mix Xcode and Ninja generators.
Apache-2.0. See file headers and repository for details.