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
Quick Start
Build Targets
Release Build
Optimized build for production use:- Optimization:
-O3 - Defines:
-DNDEBUG - Build type:
Release
Debug Build
Unoptimized build with debug symbols:- Optimization:
-O0 - Debug info:
-g - Defines:
-DDEBUG - Sanitizers: Address sanitizer and UBSan enabled by default
Release with Debug Info
Optimized build with debug symbols:Release with Assertions
Optimized build with assertions enabled:Build Options
Using Ninja for Faster Builds
Ninja provides significantly faster parallel builds:Build with Extensions
Build specific extensions:BUILD_TPCH=1- TPC-H benchmark extensionBUILD_TPCDS=1- TPC-DS benchmark extensionBUILD_HTTPFS=1- HTTP/S3 file system supportBUILD_JSON=1- JSON extensionBUILD_PARQUET=1- Parquet support (usually enabled by default)BUILD_ICU=1- International Components for Unicode
Build with Benchmarks
build/release/benchmark/benchmark_runner.
CMake Configuration
Direct CMake Usage
For more control, use CMake directly:CMake Options
Common CMake configuration options:| Option | Description | Default |
|---|---|---|
CMAKE_BUILD_TYPE | Build type: Debug, Release, RelWithDebInfo | Release |
BUILD_UNITTESTS | Build the unit test runner | TRUE |
BUILD_SHELL | Build the DuckDB CLI shell | TRUE |
BUILD_BENCHMARKS | Build benchmark suite | FALSE |
DISABLE_UNITY | Disable unity builds | FALSE |
ENABLE_SANITIZER | Enable address sanitizer (debug only) | TRUE |
ENABLE_UBSAN | Enable undefined behavior sanitizer | TRUE |
FORCE_COLORED_OUTPUT | Always produce colored output | FALSE |
Makefile Variables
Pass CMake options through make:Platform-Specific Notes
Linux
Standard build works on most distributions:macOS
Universal Binary (Intel + Apple Silicon)
Specific Architecture
Windows
Windows builds require Visual Studio:Build Artifacts
After building, you’ll find:| Artifact | Location | Description |
|---|---|---|
| Static library | build/release/src/libduckdb_static.a | Static library |
| Shared library | build/release/src/libduckdb.so | Shared library |
| CLI executable | build/release/duckdb | Command-line interface |
| Unit tests | build/release/test/unittest | Test runner |
| Benchmark runner | build/release/benchmark/benchmark_runner | Benchmark suite (if enabled) |
Compiler Cache
DuckDB automatically detects and usesccache or sccache if available (see CMakeLists.txt:41-59).
Install ccache to speed up rebuilds:
Troubleshooting
Build Failures
Out of memory during build:- Ensure GCC 8.0+ or Clang 9.0+
- Check version:
g++ --versionorclang++ --version
Clean Build
Remove all build artifacts:build/ directory.
Next Steps
Testing
Run unit tests and verify your build
Contributing
Learn how to contribute to DuckDB