ITK/HelloInsight: Difference between revisions

From KitwarePublic
< ITK
Jump to navigationJump to search
m (moved ITK HelloInsight to ITK/HelloInsight: Naming convention.)
Line 1: Line 1:
= Hello Insight =
= Hello Insight =


Traditionally, the very first program you learn to write in any given language is the simplest code to print "Hello World!".  Following in a similar vein, we hereby present the simplest possible ITK program (which also happens to print a boring message).  While it doesn't demonstrate anything very sophisticated, it can be used to demonstrate that you can build programs against your freshly installed ITK, and that you can run them.  If this seemingly trivial step succeeds, it means:
Traditionally, the very first program you learn to write in any given language is the simplest code to print "Hello World!".  Following in a similar vain, we a simple ITK program.  While simple, it is used to demonstrate that you can build programs against your freshly installed ITK and that you can run them.  If this seemingly trivial step succeeds, it means:


# ITK was built successfully (the build itself succeeded)
# ITK was built successfully (the build itself succeeded)
Line 9: Line 9:
All this working is a good thing.
All this working is a good thing.


So without further ado, fire up your favourite text editor and get started!
So without further ado, fire up your favourite text editor and let's get started!


== Hello Insight - Really ==
== Hello Insight - Really ==


Create a new directory.  Be imaginative and call it `HelloInsight`.  Create a file called `HelloInsight.cxx` therein, and enter the following code:
Create a new directory.  Be imaginative and call it ''HelloInsight''.  Create a file called ''HelloInsight.cxx'' therein, and enter the following code:


  #include <itkImage.h>
  #include <itkImage.h>
Next to ''HelloInsight.cxx'', create a file, ''CMakeLists.txt'', and populate it with:
<pre>
project(HelloInsight)
# Find ITK.
find_package(ITK Required)
include(${ITK_USE_FILE})
add_executable(HelloWorld HelloWorld.cxx )
target_link_libraries(HelloWorld ${ITK_LIBRARIES})
</pre>


{{ITK/Template/Footer}}
{{ITK/Template/Footer}}

Revision as of 03:16, 24 April 2012

Hello Insight

Traditionally, the very first program you learn to write in any given language is the simplest code to print "Hello World!". Following in a similar vain, we a simple ITK program. While simple, it is used to demonstrate that you can build programs against your freshly installed ITK and that you can run them. If this seemingly trivial step succeeds, it means:

  1. ITK was built successfully (the build itself succeeded)
  2. ITK development files were installed successfully (and your compiler can find all the right headers and libraries)
  3. The ITK runtime is good (since your OS can find the required shared libraries and so on)

All this working is a good thing.

So without further ado, fire up your favourite text editor and let's get started!

Hello Insight - Really

Create a new directory. Be imaginative and call it HelloInsight. Create a file called HelloInsight.cxx therein, and enter the following code:

#include <itkImage.h>

Next to HelloInsight.cxx, create a file, CMakeLists.txt, and populate it with:

project(HelloInsight)

# Find ITK.
find_package(ITK Required)
include(${ITK_USE_FILE})

add_executable(HelloWorld HelloWorld.cxx )

target_link_libraries(HelloWorld ${ITK_LIBRARIES})




ITK: [Welcome | Site Map]