macOS
Prerequisites
Install Xcode and Homebrew. Then, install the required packages with:
brew install git cmake ninjaBuilding DuckDB
Clone and build DuckDB as follows.
git clone https://github.com/duckdb/duckdbcd duckdbGEN=ninja makeOnce the build finishes successfully, you can find the duckdb binary in the build directory:
build/release/duckdbFor different build configurations (debug, relassert, etc.), please consult the Build Configurations page.
Troubleshooting
Build Failure: 'string' file not found
Problem: The build fails on macOS with the following error:
FAILED: third_party/libpg_query/CMakeFiles/duckdb_pg_query.dir/src_backend_nodes_list.cpp.o/Library/Developer/CommandLineTools/usr/bin/c++ -DDUCKDB_BUILD_LIBRARY -DEXT_VERSION_PARQUET=\"9cba6a2a03\" -I/Users/builder/external/duckdb/src/include -I/Users/builder/external/duckdb/third_party/fsst -I/Users/builder/external/duckdb/third_party/fmt/include -I/Users/builder/external/duckdb/third_party/hyperloglog -I/Users/builder/external/duckdb/third_party/fastpforlib -I/Users/builder/external/duckdb/third_party/skiplist -I/Users/builder/external/duckdb/third_party/fast_float -I/Users/builder/external/duckdb/third_party/re2 -I/Users/builder/external/duckdb/third_party/miniz -I/Users/builder/external/duckdb/third_party/utf8proc/include -I/Users/builder/external/duckdb/third_party/concurrentqueue -I/Users/builder/external/duckdb/third_party/pcg -I/Users/builder/external/duckdb/third_party/tdigest -I/Users/builder/external/duckdb/third_party/mbedtls/include -I/Users/builder/external/duckdb/third_party/jaro_winkler -I/Users/builder/external/duckdb/third_party/yyjson/include -I/Users/builder/external/duckdb/third_party/libpg_query/include -O3 -DNDEBUG -O3 -DNDEBUG -std=c++11 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk -fPIC -fvisibility=hidden -fcolor-diagnostics -w -MD -MT third_party/libpg_query/CMakeFiles/duckdb_pg_query.dir/src_backend_nodes_list.cpp.o -MF third_party/libpg_query/CMakeFiles/duckdb_pg_query.dir/src_backend_nodes_list.cpp.o.d -o third_party/libpg_query/CMakeFiles/duckdb_pg_query.dir/src_backend_nodes_list.cpp.o -c /Users/builder/external/duckdb/third_party/libpg_query/src_backend_nodes_list.cppIn file included from /Users/builder/external/duckdb/third_party/libpg_query/src_backend_nodes_list.cpp:35:/Users/builder/external/duckdb/third_party/libpg_query/include/pg_functions.hpp:4:10: fatal error: 'string' file not found 4 | #include <string>Solution: Users report that reinstalling Xcode fixed their problem. See related discussions on the DuckDB GitHub issues and on Stack Overflow.
Warning Attempting to reinstall your Xcode suite may impact other applications on your system. Proceed with caution.
sudo rm -rf /Library/Developer/CommandLineToolsxcode-select --installDebug Build Prints malloc Warning
Problem:
The debug build on macOS prints a malloc warning, e.g.:
duckdb(83082,0x205b30240) malloc: nano zone abandoned due to inability to reserve vm space.Solution:
To prevent this, set the MallocNanoZone flag to 0:
MallocNanoZone=0 make debugTo apply this change for your future terminal sessions, you can add the following to your ~/.zshrc file:
export MallocNanoZone=0