Which of path should set to ITK_DIR

Hello, I just build ITK with cmake. Now I have two folder, ITK_source and ITK_build. I set my ITK_DIR to ITK_build but get no head file error. And I found that some ITK module just have .obj file and no .cxx or .h. In ITK_source folder I have head file.
So could someone tell me how to set ITK_DIR, or is there some mistake in my cmake building?

The ITKConfig.cmake file in your ITK_build folder automatically includes the headers from your ITK_source folder.

There must some kind of mistake in your building, did it compile without errors?. For sanity, I would recommend a fresh start, delete ITK_build and start over.

It is normal that source files (.h, .hxx and .cxx) are in source folder, and compiled files (.obj, .lib, .dll and .exe) in the build folder. When you need to provide ITK_DIR to your own project, use ITK_build.

Thanks for reply. I got this error because I do not set CMAKE_INSTALL_PREFIX to ITK_source.
But now I got new error for itkVTKImageToImageFilter.h not found but other .h work well.
I add ITKGroup_Bridge in cmake.

This is my cmakelist:

  • set (ITK_DIR “D:\C_package\ITK_build”)
  • find_package(ITK CONFIG REQUIRED)
  • include("${ITK_USE_FILE}")
  • target_link_libraries(Reconstruction ${ITK_LIBRARIES})

Great that you are making progress.


That’s wasn’t the source of the error. CMAKE_INSTALL_PREFIX only plays a role if you install the project, which you are not doing it (and that’s ok, you are using the build tree, not the install tree). And by the way, not good to set CMAKE_INSTALL_PREFIX to the source folder, choose any other folder to install it, or leave the default value.

itkVTKImageToImageFilter.h you need to install VTK for this (or build it), and provide a VTK_DIR to your build of ITK. Please read documentation and other posts about bridging VTK with ITK.


Thank you for explaining CMAKE_INSTALL_PREFIX . I want to know under what conditions I should execute install?

Because I found that after executing the install, the lib bin and other folders are created in the folder, and the contents are almost identical to those in the build folder

The install folder does not contain intermediate build files. It is the preferred way of distributing a built version outside of your own computer.

Thank you for your quick reply, So if I want to release and debug two versions of the library, then I should install it twice and in different places, right?

You can install it in the same place. ITK gives slightly different file names to debug and release libraries. But debug version usually does not work on another computer. That is not an issue if you plan to just use ITK by an application or another library on the same computer.