VTK 9.3.0 static library build error with VS2019 compiler

I get the following, when attempting to build VTK 9.3.0 with BUILD_SHARED_LIBS=OFF and the VS2019 compiler:

vtkCommonCore-9.3.lib(vtkSMPToolsAPI.cxx.obj) : error LNK2019: unresolved external symbol “public: bool __cdecl vtk::detail::smp::vtkSMPToolsImpl<1>::IsParallelScope(void)” (?IsParallelScope@?$vtkSMPToolsImpl@$00@smp@detail@vtk@@QEAA_NXZ) referenced in function “public: bool __cdecl vtk::detail::smp::vtkSMPToolsAPI::IsParallelScope(void)” (?IsParallelScope@vtkSMPToolsAPI@smp@detail@vtk@@QEAA_NXZ)

Is this a known issue? Fixed in master already? Will a fix be put into a 9.3.1 release soon?

1 Like

UPDATE: happens in current master too

What SMP backends do you have enabled? I recently fixed shared MSVC builds at least, but was testing with 2022.

Cc: @spyridon97

The same link error is reported here: https://gitlab.kitware.com/vtk/vtk/-/issues/19178

Probably best to add your voice there. In particular because the above issue was posted for VS2022, for a Debug build, and if you’re doing a Release build with VS2019 that’s an important data point.

Re “What SMP backends do you have enabled?” – None explicitly, so whatever it defaults to

Re “the above issue was posted for VS2022, for a Debug build, and if you’re doing a Release build with VS2019 that’s an important data point” – thanks for the pointer to the issue, will do.

We are actually using VS 2022, but still with the VS 2019 toolset and CXX 17 standard.

1 Like

I went looking for differences in the various vtkSMPToolsImpl.txx files for the different backends, and this chunk popped out at me as possibly the cause of this problem:

The method causing the unresolved linker error is declared here for the STDThread backend, but never implemented anywhere. I am uncertain why this would only manifest with certain builds and not all, but … removing those 4 lines of declaration only code fixed the problem for me.

In the issue discussion for https://gitlab.kitware.com/vtk/vtk/-/issues/19178, it was pointed out to me that there IS, in fact, an implementation for vtkSMPToolsImpl<BackendType::STDThread>::IsParallelScope()

See the discussion in the issue for a link to a commit that works around the problem, whatever its root cause. The workaround/fix in the commit eliminates the default method implementation, and implements it in each of the 4 individual backends instead.