# Cylinder basic example doesn't work

**URL:** https://discourse.vtk.org/t/cylinder-basic-example-doesnt-work/7118
**Category:** Support
**Created:** [November 9, 2021, 11:00am UTC](https://discourse.vtk.org/t/cylinder-basic-example-doesnt-work/7118 "2021-11-09T11:00:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Ilmu011](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ilmu011/32/4237_2.png) [@Ilmu011](https://discourse.vtk.org/u/Ilmu011)
#### Post date: [November 9, 2021, 11:00am UTC](https://discourse.vtk.org/t/cylinder-basic-example-doesnt-work/7118/1 "2021-11-09T11:00:39Z")

</div>

I am trying to run this: [https://kitware.github.io/vtk-examples/site/Cxx/GeometricObjects/CylinderExample/](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:

 ![vtkerr](https://discourse.vtk.org/uploads/default/original/2X/d/de91f9285330db7b513a727237e03e3d015f17a4.png)

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](https://blog.titanwolf.in/a?ID=01100-d89c2d3d-b9f9-4346-b686-5ee38f4d32a4) it is implied, that it may be required to enable autoinit, so I added these lines at the top of my code:

```auto
#include <vtk-9.0/vtkAutoInit.h>

VTK_MODULE_INIT(vtkInteractionStyle);

```

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

---

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [November 10, 2021, 8:30am UTC](https://discourse.vtk.org/t/cylinder-basic-example-doesnt-work/7118/2 "2021-11-10T08:30:53Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Ilmu011](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ilmu011/32/4237_2.png) [@Ilmu011](https://discourse.vtk.org/u/Ilmu011)
#### Post date: [November 10, 2021, 11:11am UTC](https://discourse.vtk.org/t/cylinder-basic-example-doesnt-work/7118/3 "2021-11-10T11:11:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [November 10, 2021, 11:42am UTC](https://discourse.vtk.org/t/cylinder-basic-example-doesnt-work/7118/4 "2021-11-10T11:42:26Z")

</div>

Hi,

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

```cpp
#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

---

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [November 10, 2021, 10:36pm UTC](https://discourse.vtk.org/t/cylinder-basic-example-doesnt-work/7118/5 "2021-11-10T22:36:37Z")

</div>

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](https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=msvc-170), but I havent used this approach. I tend to use cmake-gui and select either ninja or the MSVC IDE when building projects.

---

<div class="post-metadata">

### Author: ![Ilmu011](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ilmu011/32/4237_2.png) [@Ilmu011](https://discourse.vtk.org/u/Ilmu011)
#### Post date: [November 11, 2021, 12:22pm UTC](https://discourse.vtk.org/t/cylinder-basic-example-doesnt-work/7118/6 "2021-11-11T12:22:55Z")

</div>

> [@Paulo\_Carvalho](#):
>
> ```auto
> #include <vtkAutoInit.h>
> VTK_MODULE_INIT(vtkRenderingOpenGL2) // VTK was built with vtkRenderingOpenGL2
> VTK_MODULE_INIT(vtkInteractionStyle)
> VTK_MODULE_INIT(vtkRenderingFreeType)
> 
> ```

Thank you very much! This solved the problem!
