@@ -57,6 +57,11 @@ target_include_directories(
5757 INTERFACE $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR} /src /duckdb_py /include >
5858)
5959
60+ # We link duckdb_static. Without this define, duckdb.h marks C API symbols
61+ # __declspec(dllimport) on Windows, producing unresolvable __imp_* references at
62+ # link time. No-op on non-Windows.
63+ target_compile_definitions (_duckdb_dependencies INTERFACE DUCKDB_STATIC_BUILD )
64+
6065# ────────────────────────────────────────────
6166# Descend into the real DuckDB‑Python sources
6267# ────────────────────────────────────────────
@@ -81,37 +86,6 @@ pybind11_add_module(
8186target_link_libraries (_duckdb PRIVATE _duckdb_dependencies )
8287duckdb_link_extensions (_duckdb )
8388
84- # ────────────────────────────────────────────
85- # Controlling symbol export
86- #
87- # We want to export exactly two symbols: - PyInit__duckdb: this allows CPython
88- # to load the module - duckdb_adbc_init: the DuckDB ADBC driver
89- #
90- # The export of symbols on OSX and Linux is controlled by: - Visibility
91- # annotations in the code (for this lib we use the PYBIND11_EXPORT macro) -
92- # Telling the linker which symbols we want exported, which we do below
93- #
94- # For Windows, we rely on just the visbility annotations.
95- # ────────────────────────────────────────────
96- set_target_properties (
97- _duckdb
98- PROPERTIES CXX_VISIBILITY_PRESET hidden
99- C_VISIBILITY_PRESET hidden
100- VISIBILITY_INLINES_HIDDEN ON )
101-
102- if (APPLE )
103- target_link_options (
104- _duckdb PRIVATE "LINKER:-exported_symbol,_duckdb_adbc_init"
105- "LINKER:-exported_symbol,_PyInit__duckdb" )
106- elseif (UNIX AND NOT APPLE )
107- target_link_options (
108- _duckdb PRIVATE "LINKER:--export-dynamic-symbol=duckdb_adbc_init"
109- "LINKER:--export-dynamic-symbol=PyInit__duckdb" )
110- elseif (WIN32 )
111- target_link_options (_duckdb PRIVATE "/EXPORT:duckdb_adbc_init"
112- "/EXPORT:PyInit__duckdb" )
113- endif ()
114-
11589# ────────────────────────────────────────────
11690# Put the object file in the correct place
11791# ────────────────────────────────────────────
0 commit comments