Compiling ITK on Linux
Contents
Install required software
Python 2.5 - http://www.python.org/ftp/python/2.5.2/python-2.5.2.msi
ITK - http://www.itk.org/ITK/resources/software.html.
The latest version was ITK 3.10.2 at the time of this writing.
Extract contents of zip package. Rename the extracted folder from InsightToolkit-3.10.2 to ITK.
In the new ITK folder, make another folder called binaries
CableSwig-ITK - http://www.itk.org/ITK/resources/software.html.
Direct download link of corresponding version: CableSwig-ITK 3.10.
Extract contents of zip package. Rename the extracted folder from CableSwig-ITK-3.10.0 to just CableSwig. Move this folder into ITK\Utilities.
CMake - http://www.cmake.org/cmake/resources/software.html.
The latest version was CMake 2.6.2 at the time of this writing.
- Download the Windows installer and install CMake
If you don't already have them, you will also need to install GCC, the C Standard Libraries, and the GNU make utility. If you use a Debian-based Linux system, the build-essential package includes all of these required tools.
Setup build system using CMake
Patch ITK LevelSet CSWIG wrapper
Open the file ITK/Wrapping/CSwig/CommonA/wrap_itkLevelSet.cxx in a text editor
Notice the typedefs in the namespace _LSN_. Copy these typedef lines from namespace _LSN_{} into namespace wrappers{}, which is found below
- Save and close the file
Running CMake
Run CMake: ./cmake-2.6.3-Linux-i386/bin/cmake-gui
Set the Where is the source code directory to the ITK folder
Set the Where to build the binaries directory to the binaries folder created earlier
Select Grouped View from the drop down list (it probably says Simple View by default)
Click the Configure button once.
A Select Generator prompt should pop up.
Select UNIX Makefiles from the drop-down list (if not already selected)
Make sure Use default native compilers is selected
Click Finish
- Wait for the configuration process to complete (should take about 5 minutes).
- Find and set the following four options in the list of configurable options:
Under BUILD group
BUILD_EXAMPLES
OFF
Under BUILD group
BUILD_SHARED_LIBS
ON
Under BUILD group
BUILD_TESTING
OFF
Under CMAKE group
CMAKE_USE_PTHREADS
OFF
Under ITK group
ITK_CSWIG_PYTHON
ON
Click the Configure button once more and wait for it to complete (about 5 minutes).
Finally, click the Generate button once to create the Makefiles and build system. Then exit the CMake program.
Build ITK
Change working directory to the ITK/binaries folder
Run make. This will take a couple of hours, maybe 2-3 hours.
- If the build process aborts at around the 76% mark, and the error messages are related to "static linkage" and "pthreads", then you might need to do the following for a workaround:
Find out what version of g++ is on your system by typing g++ --version
cd ITK/Utilities/CableSwig/GCC_XML/Support/GCC
List the contents by entering ls. Locate the version that matches your g++ version and take note of it.
- Run the following:
cp 3.4/bits/gthr-default.h X.X/bits/
where X.X should be replaced with your version. Obviously, if your version is 3.4, then this won't fix the problem.
Run make again. It should get back to 76% much quicker than before since everything to that point has already been built, and hopefully continue to 100%.
- If the build process aborts at around the 76% mark, and the error messages are related to "static linkage" and "pthreads", then you might need to do the following for a workaround:
Test ITK
Place this file in the ITK\binaries\bin folder: ITK.py
Save the following two files into any folder: Upload new attachment "dm_test.py", Upload new attachment "dm_test.bmp"
Run dm_test.py
When this completes, you should have two additional image files DanielssonDistanceMapImageFilterOutput1.png and DanielssonDistanceMapImageFilterOutput1.png that look like the following:
Upload new attachment "Output1.png" Upload new attachment "Output2.png"
