On Windows, DuckDB requires the Microsoft Visual C++ Redistributable package both as a build-time and runtime dependency. Note that unlike the build process on UNIX-like systems, the Windows builds directly call CMake.
Clang-cl
To build DuckDB on Windows, we recommend using the clang-cl compiler with the Visual Studio build tools (MSVC toolchain, Windows SDK and linker). This is the setup used by DuckDB's CI workflow.
- Install Visual Studio (or the Build Tools for Visual Studio) with the “Desktop development with C++” workload and the “C++ Clang Compiler for Windows” component. You also need Python, CMake, Ninja and a Bash shell with GNU Make (e.g., Git Bash with
makeinstalled). - Open a shell where the Visual Studio environment variables are set (e.g., the “x64 Native Tools Command Prompt” or a shell started from it).
- Run the following commands in a Bash shell from the root of the DuckDB repository:
bash
export GEN=ninja
export CC=clang-cl
export CXX=clang-cl
python scripts/windows_ci.py
make windows_release
The make windows_release target invokes CMake with the bundled extensions configuration (.github/config/bundled_extensions.cmake) and builds DuckDB in Release mode.
MSYS2 and MinGW64
DuckDB on Windows can also be built with MSYS2 and MinGW64.
Note that this build is only supported for compatibility reasons and should only be used if the clang-cl build is not feasible on a given platform.
To build DuckDB with MinGW64, install the required dependencies using Pacman.
When prompted with Enter a selection (default=all), select the default option by pressing Enter.
pacman -Syu git mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja
git clone https://github.com/duckdb/duckdb
cd duckdb
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DBUILD_EXTENSIONS="icu;parquet;json"
cmake --build . --config Release
Once the build finishes successfully, you can find the duckdb.exe binary in the repository's directory:
./duckdb.exe
Building the Go Client
Building on Windows may result in the following error:
go build
collect2.exe: error: ld returned 5 exit status
GitHub user vdmitriyev shared instructions for building the DuckDB Go client on Windows:
-
Get four files (
.dll, .lib, .hpp, .h) from theduckdb-shared-libs-windows-amd64.tar.gzarchive (calledlibduckdb-windows-amd64.zipbefore DuckDB 2.0). -
Place them to, e.g.,:
C:\duckdb-go\libs\. -
Install the dependencies following the
duckdb-goproject. -
Build your project using the following instructions:
bash
set PATH=C:\duckdb-go\libs\;%PATH%
set CGO_CFLAGS=-IC:\duckdb-go\libs\
set CGO_LDFLAGS=-LC:\duckdb-go\libs\ -lduckdb
go build