Skip to main content
DuckDB can be built from source using CMake and a C++11 compliant compiler. This guide covers the build process, options, and dependencies.

Prerequisites

Before building DuckDB, ensure you have:
  • CMake (version 3.5 or higher)
  • Python 3
  • C++11 compliant compiler:
    • GCC 8.0+ or Clang 9.0+ (Linux/macOS)
    • MSVC (Windows)
  • Git (for version information)

Optional Tools

  • Ninja: Faster parallel builds
  • ccache: Speed up rebuilds (automatically detected)

Quick Start

1

Clone the repository

git clone https://github.com/duckdb/duckdb.git
cd duckdb
2

Build the release version

make
This creates an optimized release build in build/release/.
3

Build the debug version (for development)

make debug
This creates a debug build with symbols in build/debug/.

Build Targets

Release Build

Optimized build for production use:
make release
Configuration:
  • Optimization: -O3
  • Defines: -DNDEBUG
  • Build type: Release

Debug Build

Unoptimized build with debug symbols:
make debug
Configuration:
  • Optimization: -O0
  • Debug info: -g
  • Defines: -DDEBUG
  • Sanitizers: Address sanitizer and UBSan enabled by default

Release with Debug Info

Optimized build with debug symbols:
make reldebug

Release with Assertions

Optimized build with assertions enabled:
make relassert
Useful for catching bugs in production-like builds.

Build Options

Using Ninja for Faster Builds

Ninja provides significantly faster parallel builds:
GEN=ninja make
If builds lock up your system due to memory pressure, limit parallel processes:
CMAKE_BUILD_PARALLEL_LEVEL=4 GEN=ninja make
Without Ninja, you can still parallelize:
CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) make

Build with Extensions

Build specific extensions:
BUILD_TPCH=1 BUILD_HTTPFS=1 make
Common extension flags:
  • BUILD_TPCH=1 - TPC-H benchmark extension
  • BUILD_TPCDS=1 - TPC-DS benchmark extension
  • BUILD_HTTPFS=1 - HTTP/S3 file system support
  • BUILD_JSON=1 - JSON extension
  • BUILD_PARQUET=1 - Parquet support (usually enabled by default)
  • BUILD_ICU=1 - International Components for Unicode

Build with Benchmarks

BUILD_BENCHMARK=1 BUILD_TPCH=1 make
This enables the benchmark runner in build/release/benchmark/benchmark_runner.

CMake Configuration

Direct CMake Usage

For more control, use CMake directly:
1

Configure the build

mkdir -p build/release
cd build/release
cmake -DCMAKE_BUILD_TYPE=Release ../..
2

Build the project

cmake --build . --config Release

CMake Options

Common CMake configuration options:
OptionDescriptionDefault
CMAKE_BUILD_TYPEBuild type: Debug, Release, RelWithDebInfoRelease
BUILD_UNITTESTSBuild the unit test runnerTRUE
BUILD_SHELLBuild the DuckDB CLI shellTRUE
BUILD_BENCHMARKSBuild benchmark suiteFALSE
DISABLE_UNITYDisable unity buildsFALSE
ENABLE_SANITIZEREnable address sanitizer (debug only)TRUE
ENABLE_UBSANEnable undefined behavior sanitizerTRUE
FORCE_COLORED_OUTPUTAlways produce colored outputFALSE
Example with options:
cmake -DCMAKE_BUILD_TYPE=Debug \
      -DBUILD_BENCHMARKS=1 \
      -DFORCE_COLORED_OUTPUT=1 \
      ../..

Makefile Variables

Pass CMake options through make:
# Treat warnings as errors
TREAT_WARNINGS_AS_ERRORS=1 make

# Disable unity builds
DISABLE_UNITY=1 make

# Disable sanitizers
DISABLE_SANITIZER=1 make

# Force 32-bit build
FORCE_32_BIT=1 make

Platform-Specific Notes

Linux

Standard build works on most distributions:
make

macOS

Universal Binary (Intel + Apple Silicon)

OSX_BUILD_UNIVERSAL=1 make

Specific Architecture

# Build for Apple Silicon only
OSX_BUILD_ARCH=arm64 make

# Build for Intel only
OSX_BUILD_ARCH=x86_64 make

Windows

Windows builds require Visual Studio:
mkdir build
cd build
cmake -G "Visual Studio 17 2022" ..
cmake --build . --config Release

Build Artifacts

After building, you’ll find:
ArtifactLocationDescription
Static librarybuild/release/src/libduckdb_static.aStatic library
Shared librarybuild/release/src/libduckdb.soShared library
CLI executablebuild/release/duckdbCommand-line interface
Unit testsbuild/release/test/unittestTest runner
Benchmark runnerbuild/release/benchmark/benchmark_runnerBenchmark suite (if enabled)

Compiler Cache

DuckDB automatically detects and uses ccache or sccache if available (see CMakeLists.txt:41-59). Install ccache to speed up rebuilds:
# Ubuntu/Debian
sudo apt install ccache

# macOS
brew install ccache

# Fedora/RHEL
sudo dnf install ccache

Troubleshooting

Build Failures

Out of memory during build:
CMAKE_BUILD_PARALLEL_LEVEL=2 make
Compiler too old:
  • Ensure GCC 8.0+ or Clang 9.0+
  • Check version: g++ --version or clang++ --version
Git describe errors: If you have a shallow clone:
git fetch --tags --unshallow
Or override the version:
OVERRIDE_GIT_DESCRIBE=v1.0.0 make

Clean Build

Remove all build artifacts:
make clean
This removes the entire build/ directory.

Next Steps

Testing

Run unit tests and verify your build

Contributing

Learn how to contribute to DuckDB

Build docs developers (and LLMs) love