-
Notifications
You must be signed in to change notification settings - Fork 16
Build Instructions ITK
Bernhard Froehler edited this page Jan 17, 2024
·
15 revisions
Up to Windows Build / Linux Build.
See also the official build instructions in the ITK wiki.
- 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 foritk-src-dir
(anditk-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.
- Start CMake.
- Make sure the "Advanced" checkbox is ticked.
- Specify
itk-src-dir
under "Where is the source code", and an arbitraryitk-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).
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 yourvtk-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
andOpenVR_LIBRARY
for the ITK build configuration (see Build Instructions VTK, you can and should re-use the OpenVR SDK download used there).
- 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.
- After enabling
- 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.
- 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".
- 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".
- 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
- On Unix/Linux:
- Open a command line in
itk-bin-dir
. - Depending on the chosen generator:
- If "Unix Makefiles", run
make -j 8
- the8
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 "Unix Makefiles", run
- Open a command line in
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
andCMAKE_C_FLAGS
in the CMake configuration steps above. - More recently, instead of " /FS", " /MP" needs to be added to the
CMAKE_CXX_FLAGS
andCMAKE_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.
- What helped in the past was to add " /FS" (without the quotes) to the
- 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:
Navigation:
- Up to Windows Build / Linux Build.
open_iA Documentation, licensed under CC BY-NC-SA 4.0