ITK/Examples/Instructions/ForUsers: Difference between revisions
From KitwarePublic
< ITK | Examples | Instructions
Jump to navigationJump to search
(Superbuild documentation) |
|||
Line 36: | Line 36: | ||
# Clone the examples repository | # Clone the examples repository | ||
<pre>git clone git://gitorious.org/itkwikiexamples/itkwikiexamples.git ITKWikiExamples</pre> | <pre>git clone git://gitorious.org/itkwikiexamples/itkwikiexamples.git ITKWikiExamples</pre> | ||
===You have your own versions of VTK and ITK=== | |||
* Make a directory to hold the binaries | * Make a directory to hold the binaries | ||
<pre>mkdir ITKWikiExamples-build</pre> | <pre>mkdir ITKWikiExamples-build</pre> | ||
Line 42: | Line 43: | ||
cd ITKWikiExamples-build | cd ITKWikiExamples-build | ||
ccmake ../ITKWikiExamples | ccmake ../ITKWikiExamples | ||
make | |||
</pre> | |||
===Use the Superbuild to build a proper VTK and ITK=== | |||
The ITKWikiExamples Superbuild will grab the proper versions of VTK and ITK and build all of the examples. To take advantage of the Superbuild, you will need to install [http://git-scm.com/ git]. | |||
<pre>mkdir ITKWikiExamples-Superbuild</pre> | |||
* From this build directory, run 'cmake'. | |||
<pre> | |||
cd ITKWikiExamples-Superbuild | |||
ccmake ../ITKWikiExampleSuperbuild | |||
make | make | ||
</pre> | </pre> |
Revision as of 19:08, 22 February 2012
If you want to use ITK Examples you have several options. If you are a Wiki Example Developer, go here or a Wiki Example Administrator go here.
Build an example
- Create a source directory (mkdir ExampleName)
- Copy and paste the source code under the heading ExampleName.cxx into an editor and save the file as ExampleName.cxx in the source directory you have just created.
- Copy and paste the text under the heading CMakeLists.txt into an editor and save the file as CMakeLists.txt in the same directory.
- Create a build directory (mkdir bin). This can be inside of your source directory, but it doesn't have to be.
From here, the instructions are operating system specific:
Linux
From your build directory, run
ccmake YourSourceDirectory (to create a Unix Makefile)
or
ccmake YourSourceDirectory -G YourIDE (e.g. KDevelop3)
- Press 'c' to configure.
- If CMake finds the correct location of your VTK binary build (the VTK_DIR cmake variable), and/or the ITK binary build (the ITK_DIR cmake variable) great! If not, use the arrow keys to scroll down to VTK_DIR, press enter, type the location of your VTK binary build (likely something like /home/yourname/bin/VTK), and press enter.
- Press 'c' again to reconfigure
- Press 'g' to generate
- If you generated a Unix Makefile, type 'make' in your build directory
- If you generated a project for an IDE, open the project file with your IDE
Windows
- Open CMake
- Select your CMakeLists.txt file
- Select your build system
- Click "Generate"
Build all of the examples
If you are really getting excited about learning ITK and are tired of "copy and pasting" examples over and over, you can download them all at the same time and build them all together.
- Download a tar file containing all examples. NOTE: If you get a message to try again later, hit the refresh button on your browser.
- Extract the tarball to WikiExamples.
- or
- Keep an active connection to the examples.
- Install git
- Clone the examples repository
git clone git://gitorious.org/itkwikiexamples/itkwikiexamples.git ITKWikiExamples
You have your own versions of VTK and ITK
- Make a directory to hold the binaries
mkdir ITKWikiExamples-build
- From this build directory, run 'cmake'. You will be prompted for the location of your VTK and ITK binary builds.
cd ITKWikiExamples-build ccmake ../ITKWikiExamples make
Use the Superbuild to build a proper VTK and ITK
The ITKWikiExamples Superbuild will grab the proper versions of VTK and ITK and build all of the examples. To take advantage of the Superbuild, you will need to install git.
mkdir ITKWikiExamples-Superbuild
- From this build directory, run 'cmake'.
cd ITKWikiExamples-Superbuild ccmake ../ITKWikiExampleSuperbuild make
Find a class or method using google
Type the following into the google search bar
site:itk.org/Wiki/ITK/Examples itkMedianImageFilter
- or
site:itk.org/Wiki/ITK/Examples SetRadius
Update the examples repository
If you cloned the examples repository, you can get the latest updates:
cd ITKWikiExamples git pull git@gitorious.org:itkwikiexamples/itkwikiexamples.git cd ../ITKWikiExamples-build cmake ../ITKWikiExamples make
Run all of the examples
ctest