Build Instructions ITK - 3dct/open_iA GitHub Wiki

Up to Windows Build / Linux Build.

See also the official build instructions in the ITK wiki.

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-5.2.1). 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.

Configuration

  • Start 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-5.2.1) under "Where to build the binaries".
  • Press "Configure".
  • Press "Yes" when asked whether the build directory should be created.
  • When asked, specify the desired generator; e.g. "Visual Studio 16 2019" / "Visual Studio 17 2022" 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!
  • Typically, you'll want to leave "Use default native compilers" checked; choose "Specify native compilers" if you know what you're doing and you want to use a different compiler (which you will be required to select in a next step).

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 have enabled OpenVR support in VTK, you will be asked to specify OpenVR_INCLUDE_DIR and OpenVR_LIBRARY for the ITK build configuration (see Build Instructions VTK, you can and should re-use the OpenVR SDK download used there).

Optional CMake Settings

  • Enable ITK_USE_GPU if you want to use GPU-accelerated versions of some filters. **Note: ** This requires OpenCL, see the according OpenCL Build Instructions
    • After enabling ITK_USE_GPU and pressing "Configure", either CMake doesn't find OpenCL and will print an error; or if it found OpenCL, you will want to check whether CMake found the correct OpenCL library to use:
    • Make sure OPENCL_INCLUDE_DIRS points to the include subdirectory of the OpenCL installation directory.
    • Make sure OPENCL_LIBRARIES points to the "OpenCL.lib" (Windows) / "libOpenCL.so" (Linux) situated inside the "lib" subfolder of the OpenCL installation directory (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

  • 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:

  • Windows Build Troubleshooting
  • Linux Build Troubleshooting
  • With Visual Studio 2019, you might run into the following error: fatal error C1090: PDB API call failed, error code '3':
    • This was reported as Visual Studio bug 552999 and bug 1262312. The problem should be fixed; if you still encounter it, here are two potential workarounds:
      • What helped in the past was to add " /FS" (without the quotes) to the CMAKE_CXX_FLAGS and CMAKE_C_FLAGS in the CMake configuration steps above.
      • More recently, instead of " /FS", " /MP" needs to be added to the CMAKE_CXX_FLAGS and CMAKE_C_FLAGS. On some systems, adding an environment variable "CL" with value "/MP" has helped, but on some affected systems this did not help, instead only adding it to the CMAKE_..._FLAGS has fixed the issue.

Navigation: