Runtime error with VtkToPng with VTK6+
I think this is currently only an issue with VtkToPng
but it is likely to affect any future VTK-related code that aims to make use of OpenGL functionality.
When building VtkToPng
(requires NEKTAR_UTILITY_EXTRAS
to be enabled in current master branch), the build and link are successful but trying to use the executable fails. The error I'm seeing is:
Error: no override found for 'vtkActor'
As far as I understand this is simply a result of a required implementation class not being found - presumably an object is being referenced via an interface and instantiated through some sort of factory where the actual required implementation is not known until runtime. When the implementation is known and the code tries to instantiate it, the required type is not found. I tried linking in some additional VTK rendering libraries which didn't solve the problem.
The solution is described here and there is also some further information on handling optional dependencies.
The first link suggests that if CMake is being used, the required #define
s will be automatically added but I couldn't get this to work and ended up having to add this manually. A diff of the changes I made is attached.
This is not ideal since it requires the rendering backend to be hard-coded. There must be a better way to resolve this. I've been building against OSMesa so I've had to build a version of VTK with the OpenGL backend but it looks like standard builds probably use OpenGL2 and the additional #define
and libraries that are linked need to be adjusted to support this.
Am I doing something wrong here or is someone else able to reproduce this problem? I've been able to reproduce it with VTK6 and VTK7 on Linux and Mac platforms.
Patch for current 4.4.1 release: vtktopng-4.4.1.patch