Skip to content

Build Instructions ITK

Bernhard Froehler edited this page May 22, 2020 · 18 revisions

Up to Windows Build / Linux Build.

Getting the Source Code

  • Download the latest release source archive (.zip for Windows, .tar.gz for Linux) from ITK Downloads
  • Extract to an arbitrary location from now on referred to as itk-src-dir (e.g. C:\Tools\itk\src-4.13.0). Note: On Windows, make sure that the full path you choose for itk-src-dir (and itk-bin-dir, see below) is not too long (recommendation: below 25 characters in total), otherwise you might see errors regarding the command line for moc being too long.
  • In case you (have to) use an ITK version before 4.12, check the ITK build fixes page.

Configuration

  • Run CMake.
  • Make sure the "Advanced" checkbox is ticked.
  • Specify itk-src-dir under "Where is the source code", and an arbitrary itk-bin-dir (e.g. C:\Tools\itk\bin-4.13.0)
  • Press "Configure".
  • When asked, specify the desired generator; e.g. "Visual Studio 14 2015" / "Visual Studio 15 2017" / "Visual Studio 16 2019" on Windows, or "Ninja" / "Unix Makefiles" on Linux; these generators are the ones that we use internally; choosing another generator should be no problem, but as we haven't tested them, you might encounter problems, if so please let us know!

Mandatory CMake Settings

These CMake options need to be verified/changed:

  • Enable BUILD_SHARED_LIBS
  • Enable Module_ITKVtkGlue
  • Enable Module_ITKReview
  • Enable ITK_USE_64BITS_IDS (should be enabled by default in newer ITK releases).
  • Press "Configure". It will probably result in an error regarding missing VTK libraries.
  • Set VTK_DIR to your vtk-bin-dir (Note that this will also determine the VTK library used for open_iA).
  • Press "Configure" again.
  • If you are using VTK >= 9 and have enabled OpenVR support there, you will be asked to specify OpenVR_INCLUDE_DIR and OpenVR_LIBRARY again (see Build Instructions VTK).

Optional CMake Settings

  • Enable ITK_USE_GPU (if you want to use GPU-accelerated versions of some filters. **Note: ** This requires OpenCL)
  • After pressing "Configure", you will be asked to specify the OpenCL library to use:
    • Set OPENCL_INCLUDE_DIRS to the "include" subdirectory of the OpenCL SDK installation directory.
    • Set OPENCL_LIBRARIES to the "OpenCL.lib" situated inside the "lib" subfolder of the OpenCL SDK installation directory (choose the one from the x86_64 / x64 subfolder).
    • Press "Configure" again. It should run through without errors regarding OpenCL.
  • Enable Module_HigherOrderAccurateGradient (on some ITK versions this might require also enabling Module_SplitComponents) if you plan to use higher order gradient filters from within open_iA.
  • Enable Module_SCIFIO for broader file version support. Note: Including this module has some side effects, such as getting an error message when loading files in open_iA if SCIFIO_PATH environment variable is not set to point to the jar files required by it; see also the CMake warning open_iA generates when building with ITK with SCIFIO enabled. Note that you do not require this flag to be enabled for open_iA; so unless you explicitly require the format support this library provides, we recommend disabling the flag.

Finishing configuration

  • When using a "single-configuration" generator, such as "Ninja" or "Unix Makefiles", also set CMAKE_BUILD_TYPE to the build type you want to create (e.g., Debug if you plan to fix problems in open_iA, Release if you plan to use it productively and run long-running operations). For Visual Studio generators, you don't need to create/modify this setting (it is a multi-configuration generator, the option typically even will not exist).
  • Press "Configure" one last time; if there still are errors, the corresponding messages should give you a hint as to what to do to resolve them.
  • When there are no more errors, and "Configuring done" is shown at the bottom of the log, press "Generate".

Building

  • Open itk.sln in itk-bin-dir in VS 2015, and build desired configuration(s) (for example Debug).

  • On Windows with Visual Studio:

    • Click "Open Project" (check carefully that it opens with the correct Visual Studio version in case you have multiple versions installed!), or open itk.sln in itk-bin-dir in Visual Studio
    • Build desired configuration(s) (for example Debug), e.g. via "Build"->"Build Solution", or multiple configurations at once via "Build"->"Batch Build".
  • On Unix/Linux:

    • Open a command line in itk-bin-dir.
    • Depending on the chosen generator:
      • If "Unix Makefiles", run make -j 8 - the 8 specifies the number of parallel compilations, you can adapt that to better match the number of (virtual) processor cores in your computer
      • If "Ninja, run ninja

If there are any problems, check the respective troubleshooting section:

Navigation:

Clone this wiki locally