# running and functional examples available?

**URL:** https://discourse.vtk.org/t/running-and-functional-examples-available/4865
**Category:** Support
**Created:** [December 20, 2020, 9:19am UTC](https://discourse.vtk.org/t/running-and-functional-examples-available/4865 "2020-12-20T09:19:39Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Jens](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@Jens](https://discourse.vtk.org/u/Jens)
#### Post date: [December 20, 2020, 9:19am UTC](https://discourse.vtk.org/t/running-and-functional-examples-available/4865/1 "2020-12-20T09:19:39Z")

</div>

Good day,  
OS: Windows 10 using VS2019 (C++)  
after changing from VTK 8.2 to 9.0.1 none of the examples run anymore. I compiled the cone6 example but it immediately returns from the vtkRenderWindowInteractor::Start() function.  
With an older own code previously running perfect on VTK8.2 I know, after calling vtkRenderWindowInteractor::New() the output window shows

 ![Eingefangen001](https://discourse.vtk.org/uploads/default/original/2X/d/d6073b928a5a82af4c66f0d42107a617bb1c4cf8.jpeg)  
It would be nice if the VTK team could make some of the examples runnable with the new VTK version 9.x.

---

<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: [December 20, 2020, 8:44pm UTC](https://discourse.vtk.org/t/running-and-functional-examples-available/4865/2 "2020-12-20T20:44:46Z")

</div>

Hi, Jens,

Can you try to add `VTK_MODULE_INIT(vtkInteractionStyle) ` in the beginning of the .cpp file to see whether it works?

regards,

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: [December 21, 2020, 1:29am UTC](https://discourse.vtk.org/t/running-and-functional-examples-available/4865/3 "2020-12-21T01:29:24Z")

</div>

These examples are now found in the new VTK Examples site, in particular here: [C++ Tutorial](https://kitware.github.io/vtk-examples/site/Cxx/#tutorial) they all run Ok in VTK 9+.

---

<div class="post-metadata">

### Author: ![Jens](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@Jens](https://discourse.vtk.org/u/Jens)
#### Post date: [December 22, 2020, 4:42pm UTC](https://discourse.vtk.org/t/running-and-functional-examples-available/4865/4 "2020-12-22T16:42:27Z")

</div>

Hi Paulo, Andrew,  
many thanks for your quick reply. Unfortunately both of your suggestions doesn’t work. I believe I made something wrong with my project files definition. I tried the procedure with cmake as decribed on the tutorial page but not successfull. Have created a new initial VS project and setup pathes accordingly. It compiles fine (in debug mode only) but when I step into this-\>StartEventLoop(); it does nothing and immediately returns. I changed the interactor form vtkRenderWindowInteractor to vtkWin32RenderWindowInteractor and it is processing in a loop but I can only see the command window but not the render window with the cone.  
I becomes somewhat complicated for me and without an easy to use running sample I am unable to figure out how it may work. I think I return back to version 8.2 or try to find another 3D graphics library. I like the possiblities of the vtk class library but for a 3D novice like me it’s to complicated.  
Which you a happy X- Mas and a (better than 2020) New Year!

---

<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: [December 22, 2020, 7:59pm UTC](https://discourse.vtk.org/t/running-and-functional-examples-available/4865/5 "2020-12-22T19:59:42Z")

</div>

Hi, Jens,

If you’re trying the cone example without modification, I suggest you to click on the “Open Project” button in CMake window instead of trying to create a new project. That button opens the VS solution generated by CMake without any issues. Once you get acquainted with it, you may start modifying it.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/4/454c33f63bc002af87ab67438d575fcf98e01670.png)

take care,

Paulo

---

<div class="post-metadata">

### Author: ![Jens](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@Jens](https://discourse.vtk.org/u/Jens)
#### Post date: [January 17, 2021, 2:57pm UTC](https://discourse.vtk.org/t/running-and-functional-examples-available/4865/6 "2021-01-17T14:57:54Z")

</div>

Hello Paulo,  
after playing around now I know how to get the examples compile and run. Many thanks for your suggestions.  
With the runnoimng example I was able to create an own visualstudio \*.props file which I am using as the parent setting in my own projects.  
I like to take the opportunity here to pint out that I had some difficulties to get my openGL classes to run. Finally I found the reason by examiniation of the example which includes the preporocessor macros:  
vtkRenderingContext2D\_AUTOINIT\_INCLUDE=“H:/CW/vtksample/XYPlot/build/CMakeFiles/vtkModuleAutoInit\_04d683062bbc5774e34e8c62b13e1a5a.h”  
vtkRenderingCore\_AUTOINIT\_INCLUDE=“H:/CW/vtksample/XYPlot/build/CMakeFiles/vtkModuleAutoInit\_04d683062bbc5774e34e8c62b13e1a5a.h”  
vtkRenderingOpenGL2\_AUTOINIT\_INCLUDE=“H:/CW/vtksample/XYPlot/build/CMakeFiles/vtkModuleAutoInit\_04d683062bbc5774e34e8c62b13e1a5a.h”

After examination of the header files I created an own with the following content which I use as the very first include in my projects. I found if it is included later, after including certain vtk header files, it may not work properly since the macros may be needed early during compile time. I suggest to mention this circumstances in the documentation at a prominent location:

#ifndef \_VTKBase\_h  
#define \_VTKBase\_h  
#ifndef vtkRenderingContext2D\_AUTOINIT  
#define vtkRenderingContext2D\_AUTOINIT 1(vtkRenderingContextOpenGL2)  
#endif  
#ifndef vtkRenderingCore\_AUTOINIT  
#define vtkRenderingCore\_AUTOINIT 3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL2)  
#endif  
#ifndef vtkRenderingOpenGL2\_AUTOINIT  
#define vtkRenderingOpenGL2\_AUTOINIT 1(vtkRenderingGL2PSOpenGL2)  
#endif  
#endif \_VTKBase\_h

---

<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: [January 17, 2021, 9:10pm UTC](https://discourse.vtk.org/t/running-and-functional-examples-available/4865/7 "2021-01-17T21:10:44Z")

</div>

Hi, Jens,

I use this in my `.cpp`'s to properly initialize certain VTK modules:

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

```

Maybe you need just the first `VTK_MODULE_INIT` for your case.

regards,

Paulo

---

<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: [January 17, 2021, 9:22pm UTC](https://discourse.vtk.org/t/running-and-functional-examples-available/4865/8 "2021-01-17T21:22:55Z")

</div>

If you prefer the command prompt, it is recommended to use one of the prompts that come with Visual Studio which configure the environment so the dev tools work correctly. This is especially important if you have multiple versions of Visual Studio in the same machine. These prompts have names like **VS2015 x64 Native Tools Command Prompt**.

---

<div class="post-metadata">

### Author: ![Jens](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@Jens](https://discourse.vtk.org/u/Jens)
#### Post date: [January 21, 2021, 3:38pm UTC](https://discourse.vtk.org/t/running-and-functional-examples-available/4865/9 "2021-01-21T15:38:37Z")

</div>

Hi Paulo,  
many thanks for this hint. Haven’t been aware about.

Stay safe and healthy,  
Jens
