Cylinder basic example doesn't work

I am trying to run this: https://kitware.github.io/vtk-examples/site/Cxx/GeometricObjects/CylinderExample/
basic example, but it doesn’t work. The program compiles with no errors, but at execution, I only get an empty window with this error message:

I used vcpkg to install VTK and I am using Visual Studio 2019 with MSVC to build the project.

Edit: Here: Warning: Link to vtkInteractionStyle for default style selection solution - Titan Wolf it is implied, that it may be required to enable autoinit, so I added these lines at the top of my code:

#include <vtk-9.0/vtkAutoInit.h>

VTK_MODULE_INIT(vtkInteractionStyle);

But now, instead of any errors, simply no window appears at all.

Does your CMakeLists.txt look like the one on the web page?

It’s not a CMake project. The program is built with the default MSVC-Compiler Visual Studio provides.

Hi,

I’m also not a CMake user. I had to add these to the .cpp of my VTK widget class:

#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2) // VTK was built with vtkRenderingOpenGL2
VTK_MODULE_INIT(vtkInteractionStyle)
VTK_MODULE_INIT(vtkRenderingFreeType)

I hope this helps.

cheers,

Paulo

1 Like

Unless you have a specific reason not to use CMake it is probably better you learn to use CMake. All the C++ examples rely on CMake and most users of VTK use CMake to set up their projects. CMake will automatically do a lot of the setting up for you.

Visual Studio knows about CMake CMake projects in Visual Studio, but I havent used this approach. I tend to use cmake-gui and select either ninja or the MSVC IDE when building projects.

Thank you very much! This solved the problem!

1 Like