no override found for 'vtkPolyDataMapper'

German Capuano picture German Capuano · Sep 5, 2013 · Viewed 15.8k times · Source

I'm trying to use vtk in my code, but I'm having problems running an example. I have almost no clue about the reasons since it's the first time I'm using it and I'm not very experienced. I'm using visual studio 2012 and x64 platform. Since I don't really know which libs should I use I added all of them to the "Additional Dependencies". The example is given in this link. The problem is that when I run it, the window shows this message

Generic Warning: In C:\location\VTK6.0.0\Rendering\Core\vtkPolyDataMapper.cxx, line 27
Error: no override found for 'vtkPolyDataMapper'.

which corresponds to this line

// Return NULL if no override is supplied.
vtkAbstractObjectFactoryNewMacro(vtkPolyDataMapper)

And the error that visual studio shows is

First-chance exception at 0x000007F7AA106C8F in Test.exe: 0xC0000005: Access violation reading location 0x0000000000000000.

Does anyone know how to solve this problem or at least what does this error mean?

Answer

Nikos picture Nikos · Jan 31, 2017

I too was getting this error. The error means that the linker can't find the definition for the vtkPolyDataMapper method. One has to note which vtk rendering backend they used, during build. It will probably be either vtkRenderingOpenGL, or vtkRenderingOpenGL2. Go to your build/lib folder and search for either one of these. I have VS 2015 Community and had the vtkRenderingOpenGL2, with vtk-7.1 built on Windows 8.1, x86_64 Platform, Release configuration.

I fixed the issue by inserting the 3 following lines at the very top of my source files, before any other preprocessor directives:

#include "vtkAutoInit.h" 
VTK_MODULE_INIT(vtkRenderingOpenGL2); // VTK was built with vtkRenderingOpenGL2
VTK_MODULE_INIT(vtkInteractionStyle);

This initializes the specified VTK modules. CMake includes these by default, but other compilers such as VS do not.

The last two lines can be combined into the following:

#define vtkRenderingCore_AUTOINIT 2(vtkRenderingOpenGL2, vtkInteractionStyle)