# Problem with Building ITK with Module\_ItkVtkGlue = ON

**URL:** https://discourse.itk.org/t/problem-with-building-itk-with-module-itkvtkglue-on/2315
**Category:** Beginner Questions
**Created:** [October 10, 2019, 10:22am UTC](https://discourse.itk.org/t/problem-with-building-itk-with-module-itkvtkglue-on/2315 "2019-10-10T10:22:32Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Phong\_Tran](https://discourse.itk.org/user_avatar/discourse.itk.org/phong_tran/32/1024_2.png) [@Phong\_Tran](https://discourse.itk.org/u/Phong_Tran)
#### Post date: [October 10, 2019, 10:22am UTC](https://discourse.itk.org/t/problem-with-building-itk-with-module-itkvtkglue-on/2315/1 "2019-10-10T10:22:32Z")

</div>

Hi All,

I got a problem when building ITK in release (version 5.10 in github: [https://github.com/InsightSoftwareConsortium/ITK](https://github.com/InsightSoftwareConsortium/ITK)) with setting Module\_ItkVtkGlue = ON. Actually I set VTK\_DIR points to the my latest installed VTK release at: /usr/local/lib/cmake/vtk-8.90/. But when I compile the ITK source, the compiler thew an error:

```nohighlight
In file included from /home/phongtd/workingspace/ITK/build/Wrapping/itkImageToVTKImageFilter.cxx:16:
/home/phongtd/workingspace/ITK/Modules/Bridge/VtkGlue/include/itkImageToVTKImageFilter.h:22:10: fatal error: 'vtkImageImport.h' file not found
#include "vtkImageImport.h"
         ^ ~~~~~~~~~~~~~~~~~
1 error generated.
Wrapping/Modules/ITKVtkGlue/CMakeFiles/ITKVtkGlueCastXML.dir/build.make:64: recipe for target 'Wrapping/itkImageToVTKImageFilter.xml' failed
make[2]: *** [Wrapping/itkImageToVTKImageFilter.xml] Error 1
make[2]: *** Waiting for unfinished jobs....
[29%] Generating ../../../itkPyCommand.xml
In file included from /home/phongtd/workingspace/ITK/build/Wrapping/itkVTKImageToImageFilter.cxx:16:
/home/phongtd/workingspace/ITK/Modules/Bridge/VtkGlue/include/itkVTKImageToImageFilter.h:23:10: fatal error: 'vtkImageExport.h' file not found
#include "vtkImageExport.h"
         ^ ~~~~~~~~~~~~~~~~~
1 error generated.
Wrapping/Modules/ITKVtkGlue/CMakeFiles/ITKVtkGlueCastXML.dir/build.make:70: recipe for target 'Wrapping/itkVTKImageToImageFilter.xml' failed
make[2]: *** [Wrapping/itkVTKImageToImageFilter.xml] Error 1
CMakeFiles/Makefile2:51906: recipe for target 'Wrapping/Modules/ITKVtkGlue/CMakeFiles/ITKVtkGlueCastXML.dir/all' failed
make[1]: *** [Wrapping/Modules/ITKVtkGlue/CMakeFiles/ITKVtkGlueCastXML.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[29%] Generating ../../../itkPyImageFilter.xml
[29%] Built target ITKPyUtilsCastXML
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

```

I although I cann see that file in : /usr/local/include/vtk-8.90/vtkImageImport.h. I guess ITK CMakeLists.txt did not include $VTK\_INCLUDE\_DIRS.

I tried to search on google and found the similar link: [http://itk-users.7.n7.nabble.com/Problem-with-Building-ITK-with-Module-ItkVtkGlue-ON-td30777.html](http://itk-users.7.n7.nabble.com/Problem-with-Building-ITK-with-Module-ItkVtkGlue-ON-td30777.html). But that was not a complete answer. Can anyone help me on this ?

---

<div class="post-metadata">

### Author: ![melrobin](https://discourse.itk.org/user_avatar/discourse.itk.org/melrobin/32/277_2.png) [@melrobin](https://discourse.itk.org/u/melrobin)
#### Post date: [December 22, 2019, 12:07pm UTC](https://discourse.itk.org/t/problem-with-building-itk-with-module-itkvtkglue-on/2315/2 "2019-12-22T12:07:38Z")

</div>

I am getting the same error and see that some of the include flags are not included.

---

<div class="post-metadata">

### Author: ![melrobin](https://discourse.itk.org/user_avatar/discourse.itk.org/melrobin/32/277_2.png) [@melrobin](https://discourse.itk.org/u/melrobin)
#### Post date: [December 22, 2019, 12:12pm UTC](https://discourse.itk.org/t/problem-with-building-itk-with-module-itkvtkglue-on/2315/3 "2019-12-22T12:12:35Z")

</div>

Including the VTK include directory in /ITKVtkGlue.castxml.inc seems to make progress. Now to find where this file is generated from.

---

<div class="post-metadata">

### Author: ![melrobin](https://discourse.itk.org/user_avatar/discourse.itk.org/melrobin/32/277_2.png) [@melrobin](https://discourse.itk.org/u/melrobin)
#### Post date: [December 22, 2019, 4:12pm UTC](https://discourse.itk.org/t/problem-with-building-itk-with-module-itkvtkglue-on/2315/4 "2019-12-22T16:12:13Z")

</div>

This segment shows that the include directories are set only if the VTK version is 6.0.0 or less:  
if( ${VTK\_VERSION} VERSION\_LESS 6.0.0 )  
set(ITKVtkGlue\_VTK\_INCLUDE\_DIRS ${VTK\_INCLUDE\_DIRS})  
set(ITKVtkGlue\_VTK\_LIBRARIES ${VTK\_LIBRARIES})

---

<div class="post-metadata">

### Author: ![Sophonet](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@Sophonet](https://discourse.itk.org/u/Sophonet)
#### Post date: [June 4, 2020, 6:36pm UTC](https://discourse.itk.org/t/problem-with-building-itk-with-module-itkvtkglue-on/2315/5 "2020-06-04T18:36:38Z")

</div>

I have the same problem, using the officially released versions VTK 9.0.0 and ITK 5.0.1. Indeed, when building the python wrapper, I don’t see the VTK\_INCLUDE\_DIRECTORY being considered.

The comment from melrobin (I think) is not complete: For versions later than 6.0.0, there is an ELSE() branch in CMakeLists in which exported targets seem to be considered. Nevertheless, there is a problem with VTK 8.90 and higher. Where can I start looking for a fix?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [June 5, 2020, 1:42pm UTC](https://discourse.itk.org/t/problem-with-building-itk-with-module-itkvtkglue-on/2315/6 "2020-06-05T13:42:35Z")

</div>

Possible source is [VTKGlue remote module](https://github.com/InsightSoftwareConsortium/ITKVTKGlue). I don’t know whether it is the best. @matt.mccormick might have further suggestions or advice.

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [June 8, 2020, 10:00pm UTC](https://discourse.itk.org/t/problem-with-building-itk-with-module-itkvtkglue-on/2315/7 "2020-06-08T22:00:41Z")

</div>

If building ITK Python from source, please try the functions, 'itk.vtk\_image\_from\_image`and`itk.\_image\_from\_vtk\_image`. These do not require building against a specific version of VTK Python. These will be included in the ITK 5.2.0 release.

---

<div class="post-metadata">

### Author: ![Sophonet](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@Sophonet](https://discourse.itk.org/u/Sophonet)
#### Post date: [June 9, 2020, 5:58am UTC](https://discourse.itk.org/t/problem-with-building-itk-with-module-itkvtkglue-on/2315/8 "2020-06-09T05:58:15Z")

</div>

Thanks - well, but how can I build ITK with python wrapping and with VTKGlue correctly then? I would like the C++ VTK glue to be built (for corresponding glue in C++), but also the python wrapper for scripting. It seems that this is not possible due to the compilation error? What would I need to do with ITK 5.0.1 (or 5.1.rc3) to have ITK compile correctly with VTK 9.0.0 with (C+±)VTKGlue plus Python wrapping?

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [June 10, 2020, 2:38pm UTC](https://discourse.itk.org/t/problem-with-building-itk-with-module-itkvtkglue-on/2315/9 "2020-06-10T14:38:49Z")

</div>

VTK 9.0.0 has issues with its Python wrapping and build configuration. It is recommended to use the ITKVTKGlue bridge for C++ bridge, but the referenced methods for Python.
