[Insight-users] Using compiled ITK libraries

Michael Jackson mike.jackson at bluequartz.net
Thu Apr 2 09:55:55 EDT 2009


No, you do not have to include all the ITK Source code. Here are the  
quick steps.

Build and Install ITK. MacPorts, Fink or By Hand. Make a note of the  
installation directory.

You can now just create an Xcode project and reference the needed itk  
libraries in your Xcode project. You will also have to manually setup  
all the necessary include directories for your project.

The _better_ way would be to use CMake to manage your project. You can  
look in the ITK examples directory for examples on how to write a  
CMakeLists.txt file. I personally suggest the following:

Create a project directory "itkTest'
  Within the itkTest directory create a text file called  
'CMakeLists.txt'
  Write the necessary Cmake code, save the file.

#--------- Begin CMakeLists.txt -----------
project(itkTest)

# --------------------------------------------------------------------
# Find the ITK Package
# --------------------------------------------------------------------
FIND_PACKAGE(ITK)
IF(ITK_FOUND)
   INCLUDE(${USE_ITK_FILE})
ELSE(ITK_FOUND)
   MESSAGE(FATAL_ERROR "Cannot build without ITK.  Please set ITK_DIR.")
ENDIF(ITK_FOUND)

add_executable(itkTest itkTest.cpp)
target_link_libraries(itkTest ${ITK_LIBRARIES})
#----------- End CMakeLists.txt -------------------

Write your program in the itkTest.cpp file


Next step is to generate the Xcode project. The easiest way is to open  
the "terminal.app" and navigate to the project directory. So say you  
created your project on the Desktop, then in the terminal execute the  
following commands:

cd ~/Desktop/itkTest
mkdir Build
cd Build
cmake -G Xcode ../
open itkTest.xcodeproj

At that point Xcode should launch with a brand new Xcode project ready  
to go. Try to compile and run your program.

Good Luck


_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio



On Apr 2, 2009, at 9:45 AM, bnsteel wrote:

>
> Hi,
>
> I have installed ITK on my MacPro using the macports InsightToolkit  
> and by downloading the tarball and building the binaries for XCode  
> using 'ccmake ~/InsightToolkitdir/  -GXcode' .
>
> If I open the resulting ITK.xcodeproj, I get the whole shebang in  
> XCode and
> it's pretty big and slow.  My question is: If I only want to use the  
> ITK
> libs, must I include the entire ITK source code in my project? Or  
> can I just
> link to the existing libs?
>
> I ask because in trying out the HelloWorld app, where I simply include
> "itkImage.h", I run into all sorts of problems, with errors being  
> found in
> the itk header files that all relate to the system's confusion about  
> std
> namespace items (i.e. 'cout' is not a member of 'std').  I included
> ITKCommon.a and ITKIO.a (created by the big XCode proj)and added the  
> header
> path (i.e. ~/include/InsightToolkit/**).
>
> I have tried implementing the same linker options (used by example  
> code) in my test app, but I haven't been able to stop these problems.
>
> Brooke
> -- 
> View this message in context: http://n2.nabble.com/Using-compiled-ITK-libraries-tp2575253p2575253.html
> Sent from the ITK Insight Users mailing list archive at Nabble.com.
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users



More information about the Insight-users mailing list