fix(cmake+msvc): Restore dllimport on extern template declarations (#5200)#5202
Merged
matejk merged 1 commit intopoco-1.15.1from Feb 12, 2026
Merged
fix(cmake+msvc): Restore dllimport on extern template declarations (#5200)#5202matejk merged 1 commit intopoco-1.15.1from
matejk merged 1 commit intopoco-1.15.1from
Conversation
|
I confirm this PR solves the linker error I was seeing in #5200. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#if defined(POCO_OS_FAMILY_WINDOWS)to#if defined(POCO_OS_FAMILY_WINDOWS) && defined(<Component>_EXPORTS)in allextern templatedeclarations (headers) and explicit template instantiations (.cppfiles) across Foundation, JSON, and Data/ODBCCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON) on thewindows-2025-msvc-cmakeCI job to catch this class of bug going forwardRoot cause
Commit daf19e5 stripped the API macro (e.g.
Foundation_API) fromextern template classdeclarations in headers on all Windows builds. This is correct when building the DLL (dllexportis invalid onextern templatein MSVC), but wrong when consuming the DLL — thedllimportannotation is needed so the compiler knows the instantiation lives in the DLL. Without it, consumer TUs silently generate local instantiations, which cause LNK2005 duplicate symbol errors under LTCG.The fix narrows the condition to only strip the macro when
<Component>_EXPORTSis defined (i.e. when building the DLL itself).Test plan
windows-2025-msvc-cmakejob, now with-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON)Closes #5200