Hi –

I have a C++ project that doesn’t use cmake, so vtk modules are loaded by explicitly listing the libraries in the linker arguments and using VTK_MODULE_INIT calls in the code. What is the best way to figure out which libraries to link and which modules to use with VTK_MODULE_INIT?

I tried using

WhatModulesVTK.py <vtk source> <my source>

It listed a bunch of modules in the minimal set, so I included them all in VTK_MODULE_INIT calls. At run time I got messages like this:

dyld: Symbol not found: __Z39vtkFiltersExtraction_AutoInit_Constructv
Referenced from: /Users/langer/stow/oof3d-development-debug3d-cocoa-2.7/lib/liboof3dcommon.dylib
Expected in: flat namespace

despite linking with -lvtkFiltersExtraction-8.2. In fact,

% nm -gUA libvtk*.dylib | grep FiltersExtraction_AutoInit_Construct

doesn’t find anything.

How can I find out what modules and libraries need to be included for a given VTK feature? Am I using VTK_INIT_MODULE or WhatModulesVTK.py incorrectly? Or, if FiltersExtraction_AutoInit_Construct is undefined, does it mean that I’ve built VTK incorrectly?

(FiltersExtraction is just the first of the modules listed by WhatModulesVTK.py that causes a problem – if I omit its VTK_MODULE_INIT the program actually compiles and runs. But I thought I should be able to include all of the modules that WhatModulesVTK.py lists. The actual reason that I tried using it is that I am trying to use vtkGL2PSExporter and can’t figure out how. The program will link but fails at run time with “Error: no override found for 'vtkGL2PSExporter”.)

I’m using VTK 8.2.0 on macOS Mojave.


The only modules which have an AutoInit_Construct call are those which implement object factories. FiltersExtraction doesn’t have any, so the linker error makes sense. As for finding out which modules need autoinit magic…it’s not trivial without CMake. I’d look at the modules which you use directly and then search for modules which have _IMPLEMENTS variables set in their associated module file (<module>.cmake file near the in-use VTKConfig.cmake file which have those modules in their values. With this list, you can then do the equivalent of #define vtkRenderingCore_AUTOINIT 2(vtkRenderingOpenGL2,vtkRenderingFreeType) somewhere. The count before the parentheses is the number of arguments in the parens.

It may also be easier to just do whack-a-mole if the number of in-use object factories is low.

Thank you. That was useful.

I discovered that searching for the “no override” name in build/lib/cmake/vtk-8.2/Modules/*.cmake finds it in a file whose name contains the name of the module that has to be passed to VTK_MODULE_INIT. Is that a reliable method?

– Steve

Possibly. I suspect that appears in the list of headers associated with the module. If that’s the case, then yes, it is reliable.