VTK_MODULE_INIT in 9.0.1 ?

Leaving out all of the VTK_MODULE_INITs leads to run time errors like

ImportError: /home/langer/lib/liboof3dcommon.so: undefined symbol: _ZN15vtkExtractCells8GetMTimeEv

The program compiles and links without errors, but maybe I need to link with different libraries? The link line looks like

x86_64-linux-gnu-g++ -pthread -shared ... -fPIC -std=c++11 ... -L/home/langer/lib \
[... many .o files ...]
-lvtkCommonCore-9.0 -lvtkCommonDataModel-9.0 ... --lvtkFiltersExtraction-9.0 ...

I used nm to search for the library containing vtkExtractCells and it is included in the link arguments.

The link fails because vtkExtractCells::GetMTime() was removed in VTK 9. But because it was removed, nothing should be calling it! So there is an inconsistency in your build. I suspect one of the following:

  1. Maybe your code is still picking up VTK 8.2 header files from somewhere?
  2. There might be a stale object file in your project that is being linked.

GetMTime() is still listed at https://vtk.org/doc/nightly/html/classvtkObject.html, and vtkExtractCells::GetMTime() is called in vtkExtractCellsSTLCloak::Prepare() in Filters/Extraction/vtkExtractCells.cxx. That’s from the tar file that I downloaded recently for 9.0.1.

But the compiler generates different object code depending whether GetMTime() is merely inherited, versus whether it has a definition in vtkExtractCells. In the former case, it will need the symbol _ZN9vtkObject8GetMTimeEv, but in the latter case, it will need the symbol _ZN15vtkExtractCells8GetMTimeEv.

Your best bet is to grep your object files to see which one needs _ZN15vtkExtractCells8GetMTimeEv. By this, I mean simply do the following for the same list of object files that you are compiling into your module:

fgrep -l _ZN15vtkExtractCells8GetMTimeEv *.o

Ok, thanks. I did an aggressive removal of vtk8 and removed all my object files, and I’m getting different kinds of errors now, but ones that I can understand. Is there a vtk 8 to 9 migration guide?

I’m making some progress, I think. The program compiles without errors. In order to figure out which vtk libraries I need to link with, I tried linking with none, saw what errors occurred, and added in the libraries containing the missing symbols, and repeated. That worked up to a point. But now I’m getting Error: no override found for 'vtkTexture'. The program doesn’t use textures explicitly. I’ve searched for “Texture” in all of the .o and .so files with fgrep and nm. Am I missing another library? How do I find out which libraries are required? Or is this a module initialization issue that wasn’t resolved by `FindNeededModules?

Thanks again.

The vtkTexture class is used within VTK itself for text rendering and image rendering, among other things. The override is vtkOpenGLTexture, in libvtkRenderingOpenGL2. But you must already be linking that library and have an auto-init set for it… it’s the same library has overrides for vtkRenderWindow and vtkRenderer and tons of other necessary classes. So I wonder if the ::New() method is returning NULL even though the override is present. I don’t know why that might occur, I’m just making a guess. Running it in gdb is the logical next step.

You’re likely missing the vtk_module_autoinit call. This sets up the code required to guarantee registration of the factory implementation callbacks.

If you have, for example:

add_library(foo …)
target_link_libraries(foo ${vis} # doesn't matter the visibility.
  VTK::CommonCore
  VTK::RenderingCore
  VTK::RenderingOpenGL2)

# This call ensures factory stuff works
vtk_module_autoinit(TARGETS foo
  MODULES VTK::CommonCore VTK::RenderingCore VTK::RenderingOpenGL2) # same list of VTK libraries above

I have vtk_module_init with its modules in the CMakeLists.txt file that generated the #defines that precede #include <vtkAutoInit.h>. Does cmake generate other code that I need to include?

Thanks for the vktTexture pointer. I will see what gdb says.

No, that header’s contents are all that you need. You’re probably not linking to a library that provides an implementation then (RenderingOpenGL2 seems likely)?

But I am linking to RenderingOpenGL2. I didn’t change any module settings when building vtk, but is it possible that it’s configured wrong? nm --defined-only libvtkRenderingOpenGL2-9.0.so | grep Texture prints a lot, but it’s not clear to me if that means that it contains what it should. Is that a useful test? What should I be looking for?

After upgrading to VTK 9.1, seemingly there were no need to change the autoinit procedures in my project, which is not configured and built with CMake.

The core macro machinery hasn’t changed, it’s just the CMake glue that is different now (tracked through targets rather than inferred through COMPONENT requests).