# Can't build VTK examples

**URL:** <https://discourse.vtk.org/t/cant-build-vtk-examples/7198>\
**Category:** Development\
**Created:** [November 17, 2021, 1:22am UTC](https://discourse.vtk.org/t/cant-build-vtk-examples/7198 "2021-11-17T01:22:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![totte\_karlsson](https://discourse.vtk.org/user_avatar/discourse.vtk.org/totte_karlsson/32/4281_2.png) [@totte\_karlsson](https://discourse.vtk.org/u/totte_karlsson)\
**Post date:** [November 17, 2021, 1:22am UTC](https://discourse.vtk.org/t/cant-build-vtk-examples/7198/1 "2021-11-17T01:22:01Z")

</div>

Hello,  
I’m new to this forum, and in ‘learning’ mode… 🙂

I have built VTK, version 9.0.3 successfully using Visual Studio 2019 x64. I managed to build one example manually and can verify ‘it works’.

Now I would like to build all examples from here: [https://gitlab.kitware.com/vtk/vtk-examples.git](https://gitlab.kitware.com/vtk/vtk-examples.git)

However, when firing up the cmake gui and using default settings, I get the following error:

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

Any clues on how to get past that one? I’m reading information regarding the examples, that ‘the examples are now tests’. I assume(?) this relates to the examples with in the vtk repository?

Best Regards,  
-tk

---

<div class="post-metadata">

**Author:** ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)\
**Post date:** [November 17, 2021, 9:08am UTC](https://discourse.vtk.org/t/cant-build-vtk-examples/7198/2 "2021-11-17T09:08:47Z")

</div>

Avoid building the exampe repository. You are supposed to go on the example website and try the examples you are interested into.  
[https://kitware.github.io/vtk-examples/site/](https://kitware.github.io/vtk-examples/site/)

---

<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 18, 2021, 8:37am UTC](https://discourse.vtk.org/t/cant-build-vtk-examples/7198/3 "2021-11-18T08:37:32Z")

</div>

As @mwestphal, said the best approach would be to initially get familiar with building selected examples from the web site. This will let you iron out path issues etc. in your system. Once that is done, you can move on to building all the examples.

FYI: GenericClip needs VTK to be built with Testing ON.

---

<div class="post-metadata">

**Author:** ![totte\_karlsson](https://discourse.vtk.org/user_avatar/discourse.vtk.org/totte_karlsson/32/4281_2.png) [@totte\_karlsson](https://discourse.vtk.org/u/totte_karlsson)\
**Post date:** [November 18, 2021, 4:05pm UTC](https://discourse.vtk.org/t/cant-build-vtk-examples/7198/4 "2021-11-18T16:05:58Z")

</div>

Thanks for you reply(ies).

So the above error means that VTK need to be built with ‘Testing, Tests’ being ON? I’ll look for the setting ‘TESTING\_GENERIC\_BRIDGE’, and see if I can turn that ON…

By the way, as mentioned, I am compiling example by example, but its time consuming and pretty messy.

I would say, for a beginner, that its desirable to be able to build all examples in one go, allowing a user to just select from the project manager in VS which one to debug and learn from. Perhaps there should be a disclaimer to not build the examples, for a beginner, in case the CMake files are known to be broken?

---

<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 18, 2021, 9:54pm UTC](https://discourse.vtk.org/t/cant-build-vtk-examples/7198/5 "2021-11-18T21:54:39Z")

</div>

You usually only need a few examples so it is best to search the web site.

However …  
Rebuild VTK with `VTK_BUILD_TESTING` set to `WANT`.

If this fails then there are issues in your setup.

I regularly build using ninja for Linux and ninja and VS for Windows usually weekly and have no issues.

---

<div class="post-metadata">

**Author:** ![totte\_karlsson](https://discourse.vtk.org/user_avatar/discourse.vtk.org/totte_karlsson/32/4281_2.png) [@totte\_karlsson](https://discourse.vtk.org/u/totte_karlsson)\
**Post date:** [November 19, 2021, 1:14am UTC](https://discourse.vtk.org/t/cant-build-vtk-examples/7198/6 "2021-11-19T01:14:14Z")

</div>

Hello,  
Thanks for the information that VTK need to be built with TESTING ON.

So, I recompiled VTK setting that flag to WANT, and that allowed me to build all the examples.

I can run most of them from within Visual studio, in Debug mode. See image:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/1/121526ab65fbd3996adf6aecbdca79aa4aff2ba5.png)

However, which is weird, in any example that are setting or using a color, using the vtkNamedColors class, exceptions are thrown.

So a line like this:

```auto
renderer->SetBackground(colors->GetColor3d("SlateGray").GetData());

```

causes an exception

 ![image](https://discourse.vtk.org/uploads/default/original/2X/a/a61126bc3cb32b7e49b1895e1438be6d17feed04.png)

When creating an example ‘manually’ this problem (exception) don’t happen.

This _may_ mean that there are some settings in the vtk examples cmake setup that are overriding ‘something’, or missing setting up/ loading(?) modules, causing the problem.

I have checked, using the ‘modules’ view that the proper DLL’s seem to be loaded OK.

---

<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 19, 2021, 3:42am UTC](https://discourse.vtk.org/t/cant-build-vtk-examples/7198/7 "2021-11-19T03:42:30Z")

</div>

You probably have a path problem. I just rebuilt the examples and ran Axes, no issues at all within Visual Studio.
