Problem with Building ITK with Module_ItkVtkGlue = ON

Hi All,

I got a problem when building ITK in release (version 5.10 in github: 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:

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. But that was not a complete answer. Can anyone help me on this ?

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

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

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})

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?

Possible source is VTKGlue remote module. I don’t know whether it is the best. @matt.mccormick might have further suggestions or advice.

1 Like

If building ITK Python from source, please try the functions, 'itk.vtk_image_from_imageanditk._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.

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?

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.