Skip to content

fix(algo): propagate LBUG_STATIC_DEFINE to OBJECT libs on Windows - #52

Merged
adsharma merged 3 commits into
mainfrom
fix/win-lnk4217-algo-static-define
Aug 10, 2026
Merged

fix(algo): propagate LBUG_STATIC_DEFINE to OBJECT libs on Windows#52
adsharma merged 3 commits into
mainfrom
fix/win-lnk4217-algo-static-define

Conversation

@adsharma

Copy link
Copy Markdown
Contributor

Problem

Windows link fails with a class of LNK4217 warnings, e.g.:

LINK : warning LNK4217: symbol '?getSrcNode@RelExpression@binder@lbug@@QEBA...' 
  defined in 'lbug.lib(expression_util.cpp.obj)' is imported by 
  'spanning_forest.cpp.obj' in function 'getLogicalPlan'

Root cause

The algo extension compiles its sources in three OBJECT libraries (algo_extension_main, lbug_algo_function, algo_extension_common) that are compiled independently of the final lbug_algo_extension target. On Windows the extension links lbug statically, and lbug exposes LBUG_STATIC_DEFINE as an INTERFACE compile definition — but that only reaches the final SHARED target's compilation, not the OBJECT-library compilations.

Without it, LBUG_API (in src/include/common/api.h) resolves to __declspec(dllimport) in the extension objects, so symbols actually defined in lbug.lib (e.g. binder::RelExpression::getSrcNode) are treated as imported → LNK4217.

Fix

Define LBUG_STATIC_DEFINE explicitly (PRIVATE) on each of the three OBJECT libraries on WIN32, so LBUG_API is the empty static-link ABI. POSIX is unaffected.

Follow-up

The same OBJECT-library pattern exists in httpfs, llm, and pg_client and would hit the same LNK4217 class on Windows — worth a follow-up pass in build_extension_lib or those extensions.

The algo extension compiles its sources in three OBJECT libraries
(algo_extension_main, lbug_algo_function, algo_extension_common) that are
compiled independently of the final lbug_algo_extension target. On Windows
the extension links lbug statically, and lbug exposes LBUG_STATIC_DEFINE as
an INTERFACE definition — but that only reaches the final SHARED target, not
the OBJECT-library compilations.

Without it, LBUG_API resolves to __declspec(dllimport) in the extension
objects, so symbols actually defined in lbug.lib (e.g.
binder::RelExpression::getSrcNode) are treated as imported, producing
LNK4217 at link time. Define LBUG_STATIC_DEFINE explicitly on each OBJECT
library so LBUG_API is empty (static-link ABI).
max_iterations_config.cpp lives in lbug_algo_config (src/function/config/),
a fourth OBJECT library missed by the earlier pass. Without LBUG_STATIC_DEFINE
it compiles with dllimport'd LBUG_API and triggers LNK4217 for
LogicalType/BinderException/StringUtils symbols defined in lbug.lib.
The vendored icebug Windows artifact splits NetworKit into two pieces:
a large static lib (networkit.lib) and a separate DLL + import lib for the
GlobalState singleton (networkit_state.dll/.lib). The static lib's members
(Log.cpp.obj, SignalHandling.cpp.obj) reference the GlobalState accessors via
__imp_* dllimport thunks, but the algo extension only linked networkit.lib,
so the link failed with LNK2019/LNK1120 (e.g. GlobalState::getLogLevel).

Resolve networkit_state.lib in download_icebug.cmake (both prebuilt and
ICEBUG_SOURCE_DIR paths), link it on WIN32, and copy networkit_state.dll
next to the built extension so the imports resolve at load time.
@adsharma
adsharma merged commit a195da6 into main Aug 10, 2026
2 checks passed
@adsharma
adsharma deleted the fix/win-lnk4217-algo-static-define branch August 10, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant