DuckDB-Extensions
DuckDB Extensions
This skill covers building DuckDB loadable extensions (.duckdb_extension files) using CMake and FetchContent. Extensions must include proper metadata to be loaded by DuckDB.
Instructions
When helping users build DuckDB extensions, follow these guidelines:
-
Version Matching: The extension MUST be built against the exact same DuckDB version that will load it. Use FetchContent with a specific git tag (e.g.,
v1.2.1). -
Metadata is Required: DuckDB extensions need metadata appended via the
append_metadata.cmakescript. Without this, DuckDB will reject the extension with "not a DuckDB extension" error. -
Static Linking: For portable extensions, link against
duckdb_staticwith visibility hidden and exclude-libs flags. -
Table Function State: In DuckDB 1.1+,
bind_datais const during execution. UseGlobalTableFunctionStatefor mutable state accessed viainput.global_state. -
PIC Required: Static libraries linked into the shared extension must be built with
POSITION_INDEPENDENT_CODE ON.