TubeTK/Build Instructions: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
Line 1: Line 1:
= Recommended Build Procedure =
= Recommended Build Procedure =


* Requirements:
TubeTK is known to compile on Windows, Macs, and Linux.
** CMake: http://cmake.org
 
== Overview ==
 
* Process
** Install system-level pre-requisites
** Download source
** Configure using CMake (http://cmake.org)
** Build
 
* Requirements
** The following must be installed prior to trying to build TubeTK
** CMake
** git
** git
** svn
** svn
** Qt (optional)


== Configure the build using CMake ==
* Packaged with TubeTK
** The following are automatically downloaded and built when TubeTK is built
** ITK
** VTK
** Slicer's command-line registration tools


===Create the build directory===
= Windows =


  cd ~/Projects # assuming that this is where your TubeTK source directory is located
* CMake
  mkdir tubetk-Release
* git
* svn
* Qt
 
run CMake (cmake-gui)
  Where is the source code: your TubeTK source directory
  Where to build the binaries: your new TubeTK build directory
Press the 'Configure' button


===Run CMake to configure===
== Build the Code ==


====Linux====
* Open Microsoft Visual Studio
* File -> Open -> Project/Solution -> open tubetk-Release/TubeTK.sln


* Perform the initial build using your compiler at the top-level of tubetk-Release.  This will update and build the libraries that TubeTK depends on (ex. VTK, ITK), and then build TubeTK.
** Right click on the "ALL_BUILD" project and select "Build".
* Subsequent builds should be initiated in the subdir tubetk-Release/TubeTK-Build to save time.  This will build TubeTK only.  You may have to periodically build from the top-level of tubetk-Release to get updates to the libraries that TubeTK depends on.
** Right click on the "TubeTK" project and select "Build".
= Macs =
* CMake
* git
* svn
* Qt
= Linux =
== Install system-level dependencies ==
TubeTK makes heavy use of ITK and VTK.  Each of these packages depends on a variety of system-level packages, many of which are not installed by default on Linux systems.  These dependencies are similar to the dependencies needed to install ParaView.  So, the following will install all of the dependencies needed to build VTK and ITK (as needed by ParaView and TubeTK).
  sudo apt-get build-dep paraview
* CMake
* git
* svn
* Qt
== Establish directory structure ==
mkdir ~/src
cd ~/src
== Download the source ==
git clone git://gitorious.org/tubetk/tubetk.git
mkdir ~/src/tubetk-Release
== Run CMake to configure ==
cd ~/src/tubetk-Release
ccmake ../tubetk
press 'c' to configure
== Build the code ==
Perform the initial build using your compiler at the top-level of tubetk-Release.  This will update and build the libraries that TubeTK depends on (ex. VTK, ITK), and then build TubeTK.
  cd tubetk-Release
  cd tubetk-Release
  ccmake ../tubetk_source_dir
  make -j4
  press 'c' to configure
 
Subsequent builds should be initiated in the subdir tubetk-Release/TubeTK-Build to save time.  This will build TubeTK only. You may have to periodically build from the top-level of tubetk-Release to get updates to the libraries that TubeTK depends on.
cd tubetk-Release/TubeTK-Build
  make -j4
 
 
= Trouble Shooting =


====Windows====
== Cannot find Git ==


run CMake (cmake-gui)
Where is the source code: your TubeTK source directory
Where to build the binaries: your new TubeTK build directory
Press the 'Configure' button
* If CMake complains that it cannot find Git:
* If CMake complains that it cannot find Git:
** Toggle the 'Advanced' checkbox to ON
** Toggle the 'Advanced' checkbox to ON
Line 33: Line 103:
** Toggle the 'Advanced' checkbox to OFF
** Toggle the 'Advanced' checkbox to OFF


===Confirm the following CMake variables===
== Missing libraries on build ==
 
Confirm the following CMake variables
 
* BUILD_TESTING: ON
* BUILD_TESTING: ON
* CMAKE_BUILD_TYPE: Specify Debug, Release, RelWithDebInfo or MinSizeRel
* CMAKE_BUILD_TYPE: Specify Debug, Release, RelWithDebInfo or MinSizeRel
Line 48: Line 121:
** If "ON", then you can tell TubeTK to use a VTK build that is already present on your system (using the CMake variable VTK_DIR).  See the warning below.
** If "ON", then you can tell TubeTK to use a VTK build that is already present on your system (using the CMake variable VTK_DIR).  See the warning below.


====Warning when using an existing build of ITK or VTK====
 
* If you like, you can tell TubeTK to use an ITK or VTK build that is already present on your system.
= Advanced =
* Note that TubeTK relies on ITK and VTK from 3D Slicer (https://github.com/Slicer/ITK and https://github.com/Slicer/VTK, respectively)
 
* Slicer's repositories for ITK/VTK contain enhancements that have not yet made it into the ITK/VTK repositories themselves.
== Using a pre-existing ITK or VTK installation ==
* If you get build errors similar to:
 
You can configure CMake variables to use an existing ITK or VTK installation instead of its embedded versions.  This is NOT recommended, because of inter-dependencies that require specific version of these libraries, and built using specific options, to be used.
* USE_SYSTEM_ITK: OFF
** If "ON", then you can tell TubeTK to use an ITK build that is already present on your system (using the CMake variable ITK_DIR).  See the warning below.
* USE_SYSTEM_VTK: OFF
** If "ON", then you can tell TubeTK to use a VTK build that is already present on your system (using the CMake variable VTK_DIR). See the warning below.
 
* Dependencies on ITK and VTK versions and build options
** Note that TubeTK relies on ITK and VTK from 3D Slicer (https://github.com/Slicer/ITK and https://github.com/Slicer/VTK, respectively)
** Slicer's repositories for ITK/VTK contain enhancements that have not yet made it into the ITK/VTK repositories themselves.
 
=== Build Errors ===
 
If you get build errors similar to:


  > tubetk-Release/Insight/Utilities/vxl/core/vnl/algo/vnl_svd.h: In copy constructor ‘vnl_matrix_inverse<double>::vnl_matrix_inverse(const vnl_matrix_inverse<double>&)’:
  > tubetk-Release/Insight/Utilities/vxl/core/vnl/algo/vnl_svd.h: In copy constructor ‘vnl_matrix_inverse<double>::vnl_matrix_inverse(const vnl_matrix_inverse<double>&)’:
Line 66: Line 152:
* Generally, unless you are modifying ITK or VTK yourself, it is simpler to have TubeTK build its own versions of ITK and VTK.
* Generally, unless you are modifying ITK or VTK yourself, it is simpler to have TubeTK build its own versions of ITK and VTK.


===Generate the build files===
== Recommended Compilation Options ==
 
* Reinforce the selected CMake variables by configuring a second time (press 'c' on Linux, or the 'Configure' button on Windows)
* Generate the build files by pressing 'g' on Linux, or the 'Generate' button on Windows
* '''Windows''': Close CMake when it reports "Generating done"
 
===Build TubeTK using your compiler===
 
====Linux====
 
* Perform the initial build using your compiler at the top-level of tubetk-Release.  This will update and build the libraries that TubeTK depends on (ex. VTK, ITK), and then build TubeTK.
cd tubetk-Release
make -j4
* Subsequent builds should be initiated in the subdir tubetk-Release/TubeTK-Build to save time.  This will build TubeTK only.  You may have to periodically build from the top-level of tubetk-Release to get updates to the libraries that TubeTK depends on.
cd tubetk-Release/TubeTK-Build
make -j4
 
===== Recommended Compilation Options =====


* For Linux developers (and Linux dashboard machines) we recommend:
* For Linux developers (and Linux dashboard machines) we recommend:
Line 91: Line 160:
** http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
** http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
** http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/C_002b_002b-Dialect-Options.html
** http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/C_002b_002b-Dialect-Options.html
====Windows====
* Open Microsoft Visual Studio
* File -> Open -> Project/Solution -> open tubetk-Release/TubeTK.sln
* Perform the initial build using your compiler at the top-level of tubetk-Release.  This will update and build the libraries that TubeTK depends on (ex. VTK, ITK), and then build TubeTK.
** Right click on the "ALL_BUILD" project and select "Build".
* Subsequent builds should be initiated in the subdir tubetk-Release/TubeTK-Build to save time.  This will build TubeTK only.  You may have to periodically build from the top-level of tubetk-Release to get updates to the libraries that TubeTK depends on.
** Right click on the "TubeTK" project and select "Build".


= Inside TubeTK =
= Inside TubeTK =

Revision as of 03:28, 8 March 2012

Recommended Build Procedure

TubeTK is known to compile on Windows, Macs, and Linux.

Overview

  • Process
    • Install system-level pre-requisites
    • Download source
    • Configure using CMake (http://cmake.org)
    • Build
  • Requirements
    • The following must be installed prior to trying to build TubeTK
    • CMake
    • git
    • svn
    • Qt (optional)
  • Packaged with TubeTK
    • The following are automatically downloaded and built when TubeTK is built
    • ITK
    • VTK
    • Slicer's command-line registration tools

Windows

  • CMake
  • git
  • svn
  • Qt
run CMake (cmake-gui)
Where is the source code: your TubeTK source directory
Where to build the binaries: your new TubeTK build directory
Press the 'Configure' button

Build the Code

  • Open Microsoft Visual Studio
  • File -> Open -> Project/Solution -> open tubetk-Release/TubeTK.sln
  • Perform the initial build using your compiler at the top-level of tubetk-Release. This will update and build the libraries that TubeTK depends on (ex. VTK, ITK), and then build TubeTK.
    • Right click on the "ALL_BUILD" project and select "Build".
  • Subsequent builds should be initiated in the subdir tubetk-Release/TubeTK-Build to save time. This will build TubeTK only. You may have to periodically build from the top-level of tubetk-Release to get updates to the libraries that TubeTK depends on.
    • Right click on the "TubeTK" project and select "Build".

Macs

  • CMake
  • git
  • svn
  • Qt

Linux

Install system-level dependencies

TubeTK makes heavy use of ITK and VTK. Each of these packages depends on a variety of system-level packages, many of which are not installed by default on Linux systems. These dependencies are similar to the dependencies needed to install ParaView. So, the following will install all of the dependencies needed to build VTK and ITK (as needed by ParaView and TubeTK).

 sudo apt-get build-dep paraview
  • CMake
  • git
  • svn
  • Qt

Establish directory structure

mkdir ~/src
cd ~/src

Download the source

git clone git://gitorious.org/tubetk/tubetk.git
mkdir ~/src/tubetk-Release

Run CMake to configure

cd ~/src/tubetk-Release
ccmake ../tubetk
press 'c' to configure

Build the code

Perform the initial build using your compiler at the top-level of tubetk-Release. This will update and build the libraries that TubeTK depends on (ex. VTK, ITK), and then build TubeTK.

cd tubetk-Release
make -j4

Subsequent builds should be initiated in the subdir tubetk-Release/TubeTK-Build to save time. This will build TubeTK only. You may have to periodically build from the top-level of tubetk-Release to get updates to the libraries that TubeTK depends on.

cd tubetk-Release/TubeTK-Build
make -j4


Trouble Shooting

Cannot find Git

  • If CMake complains that it cannot find Git:
    • Toggle the 'Advanced' checkbox to ON
    • Set the value of GIT_EXECUTABLE value to C:\Program Files (x86)\Git\bin\git.exe, or its equivalent on your system
    • Press the 'Configure' button twice
    • Toggle the 'Advanced' checkbox to OFF

Missing libraries on build

Confirm the following CMake variables

  • BUILD_TESTING: ON
  • CMAKE_BUILD_TYPE: Specify Debug, Release, RelWithDebInfo or MinSizeRel
  • TubeTK_USE_CTK: ON
  • TubeTK_USE_QT: OFF
    • If you have Qt 4.6.3 or greater installed, you can turn it on.
    • If you do not have Qt, CMake will complain until you turn this option off.
  • TubeTK_USE_SUPERBUILD: ON
    • If "ON", then cmake will fetch and compile ITK and VTK from the Slicer git repository, and will fetch and compile TCLAP, ModuleDescriptionParser, and GenerateCLP from the Slicer3 svn repository
  • TubeTK_USE_VTK: ON
  • USE_SYSTEM_ITK: OFF
    • If "ON", then you can tell TubeTK to use an ITK build that is already present on your system (using the CMake variable ITK_DIR). See the warning below.
  • USE_SYSTEM_VTK: OFF
    • If "ON", then you can tell TubeTK to use a VTK build that is already present on your system (using the CMake variable VTK_DIR). See the warning below.


Advanced

Using a pre-existing ITK or VTK installation

You can configure CMake variables to use an existing ITK or VTK installation instead of its embedded versions. This is NOT recommended, because of inter-dependencies that require specific version of these libraries, and built using specific options, to be used.

  • USE_SYSTEM_ITK: OFF
    • If "ON", then you can tell TubeTK to use an ITK build that is already present on your system (using the CMake variable ITK_DIR). See the warning below.
  • USE_SYSTEM_VTK: OFF
    • If "ON", then you can tell TubeTK to use a VTK build that is already present on your system (using the CMake variable VTK_DIR). See the warning below.
  • Dependencies on ITK and VTK versions and build options

Build Errors

If you get build errors similar to:

> tubetk-Release/Insight/Utilities/vxl/core/vnl/algo/vnl_svd.h: In copy constructor ‘vnl_matrix_inverse<double>::vnl_matrix_inverse(const vnl_matrix_inverse<double>&)’:
> tubetk-Release/Insight/Utilities/vxl/core/vnl/algo/vnl_matrix_inverse.h:35: instantiated from ‘void itk::tube::LDAGenerator<ImageT, LabelmapT>::GenerateLDA() [with ImageT = itk::Image<float, 2u>, LabelmapT = itk::Image<unsigned char, 2u>]’
> tubetk/Base/Filtering/itkTubeNJetLDAGenerator2F.cxx:53: instantiated from here
> tubetk-Release/Insight/Utilities/vxl/core/vnl/algo/vnl_svd.h:193: error: ‘vnl_svd<T>::vnl_svd(const vnl_svd<T>&) [with T = double]’ is private
> tubetk-Release/Insight/Utilities/vxl/core/vnl/algo/vnl_matrix_inverse.h:35: error: within this context
> tubetk/Base/Filtering/itkTubeLDAGenerator.txx: In member function ‘void itk::tube::LDAGenerator<ImageT, LabelmapT>::GenerateLDA() [with ImageT = itk::Image<float, 2u>, LabelmapT = itk::Image<unsigned char, 2u>]’:
> tubetk/Base/Filtering/itkTubeNJetLDAGenerator2F.cxx:53: instantiated from here
> tubetk/Base/Filtering/itkTubeLDAGenerator.txx:572: note: synthesized method ‘vnl_matrix_inverse<double>::vnl_matrix_inverse(const vnl_matrix_inverse<double>&)’ first required here

you likely do not have the correct version of ITK. Perhaps you have ITK from the official ITK repository instead of from 3D Slicer, or perhaps you haven't fetched updates lately?

  • Generally, unless you are modifying ITK or VTK yourself, it is simpler to have TubeTK build its own versions of ITK and VTK.

Recommended Compilation Options

Inside TubeTK

  • As noted above, TubeTK uses CMake's Superbuild include other libraries, as needed for the options selected.
  • Libraries that may be automatically downloaded and included by TubeTK include:
    • ITK
    • VTK
    • CTK
    • Select tools from the NA-MIC Kit:
      • TCLAP, GenerateCLP, ModuleDescriptionParser, RegisterImages
  • Libraries that must be externally installed if you want to use them with TubeTK
    • CMake (2.8.2 or greater - REQUIRED)
    • Qt (4.6.2 or greater - OPTIONAL)
  • You can manually install the above toolkits and then configure TubeTK to use those installations instead of building its own copies of those toolkits, BUT we don't recommend heading down that road.
    • Requires CMake expertise
    • Requires making sure each of the toolkits is correctly configured (via their own cmake configuration processes) for use with TubeTK.
    • If you still want to try this complex, manual, unsupported approach, then the following steps will help somewhat:
      1. Read tubetk/SuperBuild.cmake to find out the current set of cmake options required for each library.
      2. For example, at one point in tubetk history, you were required to build ITK v3.20.0, as mirrored and customized on the Slicer github account, using the following cmake vars
        • BUILD_SHARED_LIBS = OFF (or ON, but libs are VERY small in ITK because of templates)
        • ITK_USE_LIBXML2 = ON
        • ITK_USE_REVIEW = ON
        • ITK_USE_OPTIMIZED_REGISTRATION_METHODS = ON
        • ITK_USE_TRANSFORM_IO_FACTORIES = ON
        • CMAKE_CXX_FLAGS = -fPIC
        • CMAKE_C_FLAGS = -fPIC
          • adding -fPIC to both c and cxx flags can be ignored if you build with shared libs ON.
      3. You must also build non-cmake libraries, such as Qt 4.6.2 or greater
        • Tips for installing Open Source Qt to run with Visual Studio
          1. Open a visual studio command shell.
          2. Go to the Qt source directory and run "configure -platform win32-msvc2005". This will tell Qt to prepare itself for being compiled by the Visual Studio compiler. If you use another version of VS than 2005, replace win32-msvc-2005 with the appropriate one.
          3. Type "nmake" and take a break when it compiles.
          4. Add QMAKESPEC=win32-msvc2005 as a system environment variable and add QTDIR=your_dir into the system path. It is done.
        • Tips for installing Qt on Linux
          1. apt-get qt4
      4. After Qt, you must also build the Slicer customized version of VTK v5.6, from the Slicer github account, using the appropriate cmake vars, such as
        • BUILD_SHARED_LIBS = ON
        • VTK_USE_GUISupport = ON
        • VTK_USE_QVTK
      5. Again, many details are missing in the above list. We really recommend using Superbuild instead.

References

  • Superbuild and EXTERNAL_PROJECTS
    • Dave Cole's article in the October Kitware Source [1]