[ITK-dev] ITK Link errors: Template parent not exported

Lowekamp, Bradley (NIH/NLM/LHC) [C] blowekamp at mail.nih.gov
Mon Dec 12 11:17:35 EST 2016


Hello,

I just wanted to report what I see is going on in two simular cases of link errors in ITK and SimpleITK.


The first is ITK with VS12 and shared libraries and CMAKE_WINDOWS_ALL_SYMBOLS:BOOL=ON. It is here on the ITK dashboard [1] and here is the error:

itkPolylineMask2DImageFilterTest.cxx.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) const itk::Path,2>::`vftable'" (__imp_??_7?$Path at NV?$ContinuousIndex at N$01 at itk@@$01 at itk@@6B@) referenced in function "protected: virtual __cdecl itk::PolyLineParametricPath<2>::~PolyLineParametricPath<2>(void)" (??1?$PolyLineParametricPath@$01 at itk@@MEAA at XZ)

This error began occurring after explicit exporting of the explicitly instantiated of PolyLineParametericPath<2> was merged ( to fix other linking error )[3]. The missing symbol’s class that class's parent itk::Path<2> class, which does not get explicitly instantiated or explicitly exported.


The second linking error seems very similar. It is on the SimpleITK dashboard also with VS12 and shared libraries. This configuration does not have the CMAKE_WINDOWS_ALL_SYMBOLS enabled, just the default explicit export for VS. The errors are here [2]:

ITKOptimizersv4-4.11.lib(ITKOptimizersv4-4.11.dll) : error LNK2005: "public: virtual void __cdecl itk::ObjectToObjectOptimizerBaseTemplate::StartOptimization(bool)" (?StartOptimization@?$ObjectToObjectOptimizerBaseTemplate at N@itk@@UEAAX_N at Z) already defined in sitkImageRegistrationMethod.obj [C:\d\vs11\SimpleITK-build\SimpleITK-build\Code\Registration\src\SimpleITKRegistration.vcxproj] [C:\d\vs11\SimpleITK-build\SimpleITK.vcxproj]

This is similar because the itk::ObjectToObjectOptimiserBaseTemplate class is a parent of the explicitly exported and instantiated itk::SingleValuedNonLinearVnlOptimizerv4.

I recall a couple comments related to exporting parent template classes here:
http://review.source.kitware.com/#/c/20020/2/Modules/Numerics/Optimizersv4/include/itkLBFGSOptimizerBasev4.h
http://review.source.kitware.com/#/c/20020/6/Modules/Numerics/Optimizersv4/include/itkLBFGSOptimizerBasev4.h


My hypothesis with these error is: VS12 requires all parents in a exported explicitly instantiated template class to be exported for correct linking.

Anyone have any experience to confirm this or additional information?

Thanks,
Brad

[1] https://open.cdash.org/viewBuildError.php?buildid=4681054
[2] https://open.cdash.org/viewBuildError.php?buildid=4680972
[3] https://github.com/InsightSoftwareConsortium/ITK/commit/a94bc525c0f5911b71fcacb647245efd8306990c


More information about the Insight-developers mailing list