Skip to content

Commit 6858ca2

Browse files
committed
Build ErrorExtern into the extension module
ErrorExtern.cpp defines ccsp_set_error but was only listed in the test_c_api target, so the six other C API translation units in cspimpl referenced an undefined symbol. ELF and Mach-O permit undefined symbols in a shared object and resolve them lazily, so the Linux and macOS wheels linked and only Windows failed, with LNK1120 on _cspimpl.pyd. The module would have raised ImportError on first use everywhere. Also define CSPIMPL_EXPORTS for test_c_api. That target compiles the C API sources itself, so without it CSP_C_API_EXPORT expands to dllimport for symbols the target defines locally, which MSVC reports as LNK4217 and LNK4286. Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
1 parent 98e2266 commit 6858ca2

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

cpp/csp/python/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ add_library(cspimpl SHARED
8888
# and land directly in the extension module rather than needing the archive force-loaded.
8989
../engine/AdapterManagerExtern.cpp
9090
../engine/DictionaryExtern.cpp
91+
../engine/ErrorExtern.cpp
9192
../engine/OutputAdapterExtern.cpp
9293
../engine/PushInputAdapterExtern.cpp
9394
../engine/StringExtern.cpp

cpp/tests/engine/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ add_executable(test_c_api
2626
../../csp/engine/StringExtern.cpp
2727
../../csp/engine/TimeExtern.cpp
2828
../../csp/engine/ValueExtern.cpp)
29+
# These sources define the C API symbols, so the export macro must resolve to dllexport rather
30+
# than dllimport; without this MSVC emits LNK4217/LNK4286 for every locally defined symbol.
31+
target_compile_definitions(test_c_api PRIVATE CSPIMPL_EXPORTS)
2932
target_link_libraries(test_c_api GTest::gtest GTest::gtest_main)
3033

3134
install(TARGETS test_tick_buffer test_time_series test_partial_switch_csp_type test_dictionary test_window_buffer test_c_api

0 commit comments

Comments
 (0)