FARSIGHT Tutorials/Building Software/Building ITK
Contents |
Overview
This tutorial describes how to build ITK with the options required for using it along with FARSIGHT. In particular it includes instructions on how to build the Python wrapping using WrapITK.
Requirements
Before you proceed with this step you should have
Download ITK
The source code of ITK can be downloaded from
New releases of ITK are posted every three months.
Please use the most recent release of the software.
Configure
Define SOURCE and BINARY directories
- CMake uses the concept of SOURCE and BINARY directories
- The SOURCE directory, in this case, is the directory where you put the source code of ITK
- The BINARY directory, in this case, is the directory where you want to compile and build ITK
This is known as "out of source" building and it is strongly recommended as a good practice, as opposed to the "in-source" building where you could mix the binary and source directories into a single one, and generate great confusion and future suffering.
GNU/Linux & Mac
Create Directories
For the sake this tutorial, lets assume that you are using
- SOURCE directory = $HOME/src/Insight
- BINARY directory = $HOME/bin/InsightWithPython
That means that you expanded the source code of ITK in the directory "$HOME/src/Insight" and that you manually created the directory "$HOME/bin/InsightWithPython" with a command such as
cd mkdir InsightWithPython
Select Compiler
Select your compiler by setting the environment varialbles CC and CXX
For example, if you are using zsh:
export CC=/usr/bin/gcc-4.1 export CXX=/usr/bin/g++-4.1
or if you are using bash:
setenv CC /usr/bin/gcc-4.1 setenv CXX /usr/bin/g++-4.1
You want to use the explicit name of the compiler along with its version (gcc-4.1) as opposed to the generic name of the compiler (gcc). In this way, if you later update your compiler in this computer, your build of ITK will still use the proper compiler consistently.
Run ccmake
Then you should move into the BINARY directory run "ccmake" in order to configure ITK. When you run "ccmake" you provide the SOURCE directory as an argument.
cd InsightWithPython ccmake $HOME/src/Insight
This will show an image such as:
hit the "c" key in order to "configure". At this point CMake will test the capabilities of your compiler, after a couple of minutes it will show you an image similar to:
Do the following:
- Turn OFF the option BUILD_EXAMPLES
- Turn OFF the option BUILD_TESTING
- Turn ON the option BUILD_SHARED
- Write "Release" in the option CMAKE_BUILD_TYPE
- Hit the "c" key again in order to configure with these changes
CMake will then show you a screen similar to:
- Now pass to the advance variables by hitting the "t" key (for "toggle to advanced") and
- Hit the "/" key (for "search") and type "WRAP_ITK" in order to jump to the option that can turn wrapping ON
- Turn ON the option USE_WRAP_ITK