# Installing and building SNAP on a UNIX System

SnAP is distributed as a part of the ITK Applications installation. In order to build SNAP on a UNIX or Linux platform, the one must install ITK, VTK and FLTK on their system. This document will guide you through that process.

The following software must be installed on your system:

- CVS
- GCC C++ compiler (or another compiler supported by ITK)
- CMake (available from www.cmake.org)

### 1. Directory Structure

Create the following directory structure, which is recommended and will be assumed in this document.Replace the directory basedir with your own directory name, i.e., /home/myuserid/tk. Experienced users can change the names and order of the subdirectories to their preference.

      basedir/
      basedir/app                          // Base directory for ITK applications
      basedir/app/bingcc                   // ITK Applications binary directory

      basedir/itk                          // Base directory for ITK
      basedir/itk/bingcc                   // ITK binary directory

      basedir/vtk                          // Base directory for VTK
      basedir/vtk/bingcc                   // VTK binary directory

      basedir/fltk                         // FLTK directory

### 2. Install ITK

We will use CVS to download ITK. For more instructions, please refer to the ITK Software Guide located at www.itk.org

These instructions recommend that you download the release 1.4 of ITK. To use the latest version of ITK (at your own risk), remove the -r option in the cvs commands below.

1. Change directory to basedir/itk
2. Execute the following commands to download ITK. This will take several minutes.

           cvs -d :pserver:anonymous@www.itk.org:/cvsroot/Insight login
           (respond with password insight)

           cvs -d :pserver:anonymous@www.itk.org:/cvsroot/Insight co Insight

3. Change the directory to basedir/itk/bingcc
4. Execute the CMake command:

           ccmake ../Insight

5. The CMake user interface will appear. Set the following options in this interface:

           BUILD_EXAMPLES = OFF
           BUILD_TESTING = OFF
           CMAKE_BUILD_TYPE = Release

6. Use the c command to configure ITK and use the g command to generate makefiles
7. The following command will build ITK. This will take a while.

           make

At this point, you will have a working installation of ITK on your system. Please refer to ITK documentation for troubleshooting information.

### 3. Install VTK

VTK installation is similar to the installation of ITK.

These instructions recommend that you download the release 4.2 of VTK. To use the latest version of ITK (at your own risk), remove the -r option in the cvs commands below.

1. Change directory to basedir/vtk
2. Execute the following commands to download VTK. This will take several minutes.

           cvs -d :pserver:anonymous@public.kitware.com:/cvsroot/VTK login
           (respond with password vtk)

           cvs -d :pserver:anonymous@public.kitware.com:/cvsroot/VTK co -r LatestRelease VTK

3. Change the directory to basedir/vtk/bingcc
4. Execute the CMake command:

           ccmake ../VTK

5. The CMake user interface will appear. Set the following options in this interface:

           BUILD_EXAMPLES = OFF
           BUILD_TESTING = OFF
           CMAKE_BUILD_TYPE = Release
           VTK_USE_HYBRID = ON
           VTK_USE_PARALLEL= ON
           VTK_USE_RENDERING= ON

6. Use the t command to show advanced VTK options, and set the following options:

           VTK_USE_ANSI_STDLIB = ON

7. Use the c command to configure VTK and use the g command to generate makefiles
8. The following command will build VTK. This will take a longer while.

           make

At this point, you will have a working installation of ITK and VTK on your system. Please refer to VTK documentation (at www.vtk.org) for troubleshooting information.

### 4. Install FLTK

FLTK is a multiplatform GUI toolkit. SnAP has been developed and tested using version 1.1.2 of FLTK, but later 1.1.* versions should work as well. In all the following commands, replace the * character with the correct version number, the current version is 1.1.4

1. Download the 1.1.x FLTK tarball fltk-1.1.*-source.tar.gz from www.fltk.org/software.php. You will have to follow some links to start the download.
2. Place the downloaded file fltk-1.1.*-source.tar.gz into the basedir/fltk directory. Execute the following command to uncompress FLTK

           tar -xzvf fltk-1.1.*-source.tar.gz

3. [Linux, optional]: to enable anti-aliased fonts on Linux, in the following step pass the option --enable-xft to the ./configure command.
4. Go to the directory basedir/fltk/fltk-1.1.*/ and execute the following commands:

           ./configure
           make
           make fluid

At this point, you will have a working installation of FLTK on your system. Please refer to FLTK documentation (at www.fltk.org) for troubleshooting information.

### 5. Install the ITK InsightApplications directory

We will use CVS to download ITK Applications, including SNAP. For more instructions, please refer to the ITK Software Guide located at www.itk.org

1. Change directory to basedir/app
2. Execute the following commands to download ITK Applications. This will take several minutes.

           cvs -d :pserver:anonymous@www.itk.org:/cvsroot/Insight login
           (respond with password insight)

           cvs -d :pserver:anonymous@www.itk.org:/cvsroot/Insight co InsightApplications

3. Change the directory to basedir/app/bingcc
4. Execute the CMake command:

           ccmake ../InsightApplications

5. The CMake user interface will appear. Set the following options in this interface:

           BUILD_EXAMPLES = OFF
           BUILD_TESTING = OFF
           CMAKE_BUILD_TYPE = Release
           ITK_DIR = basedir/itk/bingcc
           USE_VTK = ON
           USE_FLTK = ON

6. Use the c command to configure InsightApplications. More options will appear:

        VTK_DIR = basedir/vtk/bingcc
        FLTK_BASE_LIBRARY = basedir/fltk/fltk-1.1.*
        FLTK_FLUID_EXECUTABLE = basedir/fltk/fltk-1.1.*/fluid/fluid

7. Use the c command to configure InsightApplications and use the g command to generate makefiles
8. To build all InsightApplications, including SNAP execute the following command. Alternatively, to only build SNAP, first change directory to basedir/app/bingcc/SNAP and run the same command.

           make

At this point, you will have a working installation of ITK InsightApplications on your system. Please refer to ITK documentation for troubleshooting information.

#### 6. Running SNAP

1. Change directory to basedir/app/bingcc/SNAP
2. Run the SNAP executable

           ./SNAP

If all goes well, SNAP user interface will launch.

#### 7. Troubleshooting

For troubleshooting the installation of ITK, VTK, FLTK and InsightApplications, please refer to the corresponding web sites noted above

We recommend that you join the ITK users mailing list, where you can find answers to questions posed by other users as well as post your own questions.