Skip to content

Building from Source

Tool Purpose
Git To clone the repository with submodules
CMake 3.28+ Configure the build
Ninja Build backend
GCC or Clang (gcc/g++ or clang/clang++) Host compiler
Zig Only for cross builds (it ships its own libc)
Visual Studio 2015+ (C/C++ tools) Windows native builds only
Terminal window
git clone --recursive https://github.com/yapb/yapb
cd yapb

The submodules (crlib, linkage, mbedtls) are required. If you already cloned without --recursive, run git submodule update --init --recursive.

build.sh is a helper script that wraps CMake presets:

Terminal window
# native dev build (host compiler, no zig needed)
./build.sh
# cross build for a specific target via zig
./build.sh --arch=linux-x86
# native build with clang, tuned for this machine, 8 parallel jobs
./build.sh -c=clang --native -j=8

Available options:

Option Description
--arch=<preset> Build preset (default: release). Cross presets need zig on PATH
-c= / --compiler= Host C/C++ compiler for native builds (gcc or clang)
-j= / --jobs= Parallel build jobs (default: ninja auto-detects)
--native Tune for this machine (-march=native)
--skip-checks Skip environment probing
-D<Var>=<Val> Extra CMake defines forwarded to the configure step

The presets mirror the CI matrix, so you can drive CMake yourself:

Terminal window
# native development build
cmake --preset release
cmake --build --preset release

Preset groups:

  • Local presets (host compiler, no zig needed): release, dist, linux-amd64-asan, linux-x86-asan
  • Cross presets (need zig on PATH): ci-linux-x86, ci-linux-amd64, ci-linux-x86-nosimd, ci-linux-arm64, ci-linux-riscv64, ci-apple-amd64, ci-windows-x86-clang, ci-windows-amd64
  • CI-only presets (their runners, not for local use): ci-apple-arm64, ci-windows-x86, ci-windows-x86-clang-cl, ci-windows-x86-msvc-xp

See CMakePresets.json for the full matrix.

  1. Install the requirements:

    Terminal window
    sudo apt update
    sudo apt install git cmake ninja-build gcc g++ gcc-multilib g++-multilib
  2. Get the source (see above)

  3. Build:

    Terminal window
    ./build.sh
  4. You’re done! The compiled library is located at release/yapb.so (each preset builds into a directory named after itself)

  1. Install Visual Studio with the C/C++ workload

  2. Get the source (see above)

  3. Either open vc/yapb.sln in Visual Studio and build, or use the cross presets through Zig from a bash shell (Git Bash/WSL):

    Terminal window
    ./build.sh --arch=windows-x86-clang
  4. You’re done! The compiled library is located at release/yapb.dll for native builds, or windows-x86-clang/yapb.dll for the cross preset

These CMake options can be passed with -D<Var>=<Val> (or through build.sh -D<Var>=<Val>):

Option Default Description
64BIT OFF Build as 64-bit binary
NATIVE OFF Configure compiler for a native machine build (-march=native)
WINXP OFF Configure MSVC build for a Windows XP compatible binary
NOSIMD OFF Disable all SIMD/NEON optimizations
STATIC_LINKENT OFF Use predefined entity link list
LTO ON Enable link-time optimization
SANITIZE (empty) Enable sanitizers, e.g. address or address,undefined (dev builds)
WITH_TLS ON Enable HTTPS support via vendored mbedtls