VTK/VTK 6 Migration/Factories now require defines

From KitwarePublic
< VTK
Revision as of 07:34, 11 August 2013 by David.cole (talk | contribs)
Jump to navigationJump to search

"I've done all this, it compiles and links, but now "New()" returns NULL at runtime"

If you build your project with CMake, and you use the standard find_package(VTK) and include(${VTK_USE_FILE}) then this problem should not occur. (Because the defines will be automatically added for you by virtue of the include(${VTK_USE_FILE})...)

The factory methods now require "auto-initialization" depending on what modules are enabled at VTK configure time. If you are enabling all modules, and building your project without using CMake, you will need some defines in your project in order to make the factories work properly.

Try including this snippet in all your code that includes VTK usage, BEFORE including ANY VTK header files:

 #define vtkRenderingCore_AUTOINIT 4(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingFreeTypeOpenGL,vtkRenderingOpenGL)
 #define vtkRenderingVolume_AUTOINIT 1(vtkRenderingVolumeOpenGL)

See these references (and follow the mailing list threads to their conclusions) for more info: