How to develop an Osirix Plugin - part 3: ITK
You want to use other version of ITK? Here is a solution that worked for me. It is based on a Tutorial by Brian Jensen.
- Update 2017-08-12: Check the new version of this tutorial.
ITK
- Get ITK source code. Lets name path of the directory with source
<ITK_src>
and one with binaries<ITK_bin>
. - Run Cmake.
- Configure with
Unix makefiles
. - Change
CMAKE_OSX_ARCHITECTURES
toi386
(see pic below). - Generate.
- Refactor namespace using
refactor_namespace.sh
from NMSegmentation or PetSpectFusion directory. You have it in your<osirix_plugins_dir>
(same where_help/Osirix Plugin Generator.app
is). To do so start terminal, go to<osirix_plugins_dir>/NMSegmentation
directory and type:sh refactor_namespace.sh <ITK_src> nmITK
sh refactor_namespace.sh <ITK_bin> nmITK
or change nmITK to any other namespace name you like. - In terminal go to
<ITK_bin>
and typemake
. - You are going to encounter some errors (see pics below), here is how I dealt with them:
Error1: fatal errror: 'nmITKsys/SystemTools.hxx' file not found
Solution1: Using Sublime text editor I found all files with nmITKsys
string and replaced it with itksys
.
Error2: error: unterminated /*
in <ITK_src>/Module/ThirdParty/GDCM
Solution2: copy whole GDCM folder from <ITK_src>
with no refactor namespace
Error3: error: use of undeclared identifier 'itkv3'
Solution3: Replace itkv3::
with nmITKv3::
similarly to Solution1.
Error4: some errors in itkTestDriverAfterTest.inc
Solution4: none yet, but not necessary :)
Osirix Plugin
- Generate new plugin, copy the code from the botttom of the post (sligtly different from the one in previous post). Remember to change the file to
.mm
. - In
<your_plugin_dir>
, using terminalln -s
, create symbolic links to ITK source code (hereITK48_src
) and binaries folders (hereITK48_bin
). - Go to Build Settings, change Base SDK to Latest OSX.
- In Build Settings, change OS X Deployment Targer to Compiler Default.
- In Build Settings fill Header search paths with:
ITK48_bin/Modules/ThirdParty/VNL/src/vxl/vcl
ITK48_bin/Modules/ThirdParty/VNL/src/vxl/core
ITK48_bin/Modules/Core/Common/**
ITK48_src/Modules/ThirdParty/VNL/src/vxl/vcl
ITK48_src/Modules/ThirdParty/VNL/src/vxl/core
ITK48_src/Modules/Core/Common/**
ITK48_src/Modules/Filtering/**
- In Build Phases add ITK libraries in Link binary with libraries (see figure below). You can move them to suitable group in XCode navigator.
- It complies, you can run it (how to turn on debugging). But the plugin won’t load. I get
nmITK10DataObject
error: - There is a problem with the linker and dynamic lookup it performes. To solve it:
- in Build Settings remove
-undefined dynamic lookup
from other linker flags - in Build Settings add Osirix binary path (mine is
/Applications/OsiriX Lite.app/Contents/MacOS/OsiriX
) in Bundle loader to let the linker know where it should look for the Osirix symbols.
- in Build Settings remove