# Building slicer with latest VTK

**URL:** <https://discourse.slicer.org/t/building-slicer-with-latest-vtk/9083>\
**Category:** Development\
**Created:** [November 8, 2019, 2:49pm UTC](https://discourse.slicer.org/t/building-slicer-with-latest-vtk/9083 "2019-11-08T14:49:01Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 8, 2019, 2:49pm UTC](https://discourse.slicer.org/t/building-slicer-with-latest-vtk/9083/1 "2019-11-08T14:49:01Z")

</div>

More and more VTK problems are surfacing for which it is very hard to find the potential VTK patches that we could backport (virtual reality Qt widget, [plot marker style issue](https://discourse.slicer.org/t/setting-of-markerstyle-does-not-work/9073/9), etc.). So, it is time to bit the bullet and try to switch to the latest VTK master.

I tried it on Windows, quickly failed with vtkWrappingTools-8.90.lib not found, and asked help on VTK forum (see [here](https://discourse.vtk.org/t/vtk-build-fails-cannot-open-input-file-lib-release-vtkwrappingtools-8-90-lib/2074)).

I’ll use this topic to give updates on my efforts and ask for help.

@jcfr @Sam_Horvath @cpinter @pieper

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 8, 2019, 3:00pm UTC](https://discourse.slicer.org/t/building-slicer-with-latest-vtk/9083/2 "2019-11-08T15:00:59Z")

</div>

Makes sense - probably if you fix on windows the solutions should transfer to other platforms, but if you want me to try mac or linux builds let me know.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 8, 2019, 3:21pm UTC](https://discourse.slicer.org/t/building-slicer-with-latest-vtk/9083/3 "2019-11-08T15:21:31Z")

</div>

Yes, it would be great if you could try it on Mac, too. I’ve pushed what I have now to a branch and submitted a pull request: [https://github.com/Slicer/Slicer/pull/1252](https://github.com/Slicer/Slicer/pull/1252). You can push changes directly to that branch (all maintainers should have write access).

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [November 8, 2019, 3:27pm UTC](https://discourse.slicer.org/t/building-slicer-with-latest-vtk/9083/4 "2019-11-08T15:27:00Z")

</div>

Agreed, the transition to latest VTK is long overdue.

I anticipate the following challenges:

- wrapping of our VTK classes, I don’t think the new VTK build system allows to externally wrap VTK classes without using the VTK build system (like what ParaView is doing)
- building of extension like SlicerVR

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 8, 2019, 3:39pm UTC](https://discourse.slicer.org/t/building-slicer-with-latest-vtk/9083/5 "2019-11-08T15:39:02Z")

</div>

VTK wrapping of external code may have been removed from VTK but it is reimplemented for example in vtkDICOM by David Gobbi: [https://github.com/dgobbi/vtk-dicom/blob/master/CMakeLists.txt](https://github.com/dgobbi/vtk-dicom/blob/master/CMakeLists.txt). It belongs into VTK, since this will be needed by many other libraries, but for now we can copy-paste the solution of vtkDICOM. Probably @jcfr we’ll need your help with this.

vtkOpenVR is a very special case, because it is a remote module with its source code stored in the VTK main repository. This “neither here nor there” state does not make much sense for me, maybe it is like this for Ken’s convenience, and maybe it has been changed since VTK-8.2. I guess it will either become a proper remote module (like spline reslicer or dicom) or a regular built-in VTK module. If it becomes a built-in module we lose the ability to do updates for stable releases and we’ll be forced to ship third-party DLLs with Slicer core. These limitations are tolerable, but it would be better if vtkOpenVR would simply become a remote module.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 9, 2019, 11:34pm UTC](https://discourse.slicer.org/t/building-slicer-with-latest-vtk/9083/6 "2019-11-09T23:34:01Z")

</div>

> [@lassoan](#):
>
> I tried it on Windows, quickly failed with vtkWrappingTools-8.90.lib not found, and asked help on VTK forum (see [here](https://discourse.vtk.org/t/vtk-build-fails-cannot-open-input-file-lib-release-vtkwrappingtools-8-90-lib/2074)).

This problem has been resolved (it was caused by a recent regression in VTK master - now fixed).

Next [problem came up during CTK configuration](https://discourse.vtk.org/t/build-error-in-vtk-based-project-include-called-with-wrong-number-of-arguments-include-only-takes-one-file/2078). It was due to VTK\_USE\_FILE not being generated at all (instead of creating a placeholder file). I’ll implement a check in CTK to only attempt to use the file for old VTK versions.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 11, 2019, 7:31pm UTC](https://discourse.slicer.org/t/building-slicer-with-latest-vtk/9083/7 "2019-11-11T19:31:22Z")

</div>

It seems that vtkWrapPython.cmake and vtkWrapHierarchy.cmake files are gone in VTK-8.90 and it is replaced by [vtkModuleWrapPython.cmake](https://github.com/Kitware/VTK/blob/master/CMake/vtkModuleWrapPython.cmake), which can wrap complete modules.

@jcfr What do you think would be a good approach? I don’t think we would want to make all Slicer components VTK modules, so vtkModuleWrapPython would not be directly applicable. Should we copy-paste Python wrapper CMake scripts from VTK-8.2 to Slicer and maintain them?

I’ve asked on the VTK forum, too: [https://discourse.vtk.org/t/vtkwrappython-disappeared-from-vtk-8-90/2084](https://discourse.vtk.org/t/vtkwrappython-disappeared-from-vtk-8-90/2084).

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 12, 2019, 2:00pm UTC](https://discourse.slicer.org/t/building-slicer-with-latest-vtk/9083/8 "2019-11-12T14:00:09Z")

</div>

@jcfr We need to make a decision about Python wrapping. Please review the option listed [here](https://discourse.vtk.org/t/vtkwrappython-disappeared-from-vtk-8-90/2084/4) and add your comments. Thanks!

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [January 31, 2020, 8:11pm UTC](https://discourse.slicer.org/t/building-slicer-with-latest-vtk/9083/9 "2020-01-31T20:11:26Z")

</div>

My [continuation](https://github.com/NA-MIC/ProjectWeek/blob/master/PW33_2020_GranCanaria/Projects/VTKBuild/README.md) of @lassoan’s work can be found in this PR:

> <https://github.com/Slicer/Slicer/pull/1312>

There are two errors, neither preventing Slicer build. However, there is an error about not finding a python dll on startup. At least a bit more work is needed.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [February 1, 2020, 6:20pm UTC](https://discourse.slicer.org/t/building-slicer-with-latest-vtk/9083/10 "2020-02-01T18:20:02Z")

</div>

Thanks for the update 🙏

> [@cpinter](#):
>
> here is an error about not finding a python dll on startup

If I recall, the issue was related to also passing `Python3_*` variables to external project expecting it. More details at [CLI - When module is entered - WidgetRepresentation should be reset to match associated node · Issue #1312 · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/pull/1312#issuecomment-581054327)
