Difference between revisions of "Slicer3:Build Instructions"

From Slicer Wiki
Jump to: navigation, search
Line 153: Line 153:
  
 
Note: The Apple X11 application on Mac OSX 10.5.x (Leopard) crashes frequently.  We suggest you replace the default XX with [http://xquartz.macosforge.org/trac/wiki XQuartz].
 
Note: The Apple X11 application on Mac OSX 10.5.x (Leopard) crashes frequently.  We suggest you replace the default XX with [http://xquartz.macosforge.org/trac/wiki XQuartz].
 +
 +
== getbuildtest on Solaris ==
 +
 +
The notes on package requirement and build instructions were contributed by Attila Nagy.
 +
 +
* Package requirements [http://www.orl.szote.u-szeged.hu/~attila/package.requirements.Slicer.on.Solaris.html http://www.orl.szote.u-szeged.hu/~attila/package.requirements.Slicer.on.Solaris.html]
 +
 +
* Build instructions [http://www.orl.szote.u-szeged.hu/~attila/slicer.build.instructions.html http://www.orl.szote.u-szeged.hu/~attila/slicer.build.instructions.html]
 +
<pre>
 +
Getbuildtest on Solaris
 +
 +
To build Slicer on Solaris, the best practice is to install the OS with Entire Distribution + OEM Support.
 +
This way all needed libraries and tools will be there. Solaris 10, Solaris eXpress Community Edition (SXCE),
 +
and Solaris eXpress Developer Edition (SXDE) 1/08 are all tested.
 +
 +
The needed packages are:
 +
SUNWgcc SUNWgmake SUNWcvs SUNWsvn SUNWTcl SUNWxwplt SUNWxorg-mesa SUNWxorg
 +
In case there are missing packages, yout can install them from the install CD/DVD.
 +
Put it in the drive, or mount the iso via lofi, and browse to the Solaris_10/Product
 +
(or Solaris_11/Product in case of SXCE/SXDE) directory, and
 +
pkgadd -d . SUNWgcc SUNWgmake SUNWcvs SUNWsvn SUNWTcl SUNWxwplt SUNWxorg-mesa SUNWxorg
 +
 +
Make sure to put /usr/sfw/bin in your path, so the build tools find gcc/g++. Compilation
 +
with Sun's compilers (cc/CC) is not yet fully supported, but work is on the way.
 +
 +
If you need, you can install newer versions of the above tools either from blastwave, or
 +
from sunfreeware. In both cases check your paths! Put /opt/csw/bin in case of blastwave,
 +
and /usr/local/bin in case of sunfreeware in your profile, and replace "/usr/sfw/bin/g++"
 +
in Slicer3/slicer_variables.tcl with the updated paths.
 +
 +
You can check your 3D acceleration by running: /usr/X11/demo/glxgears
 +
Best results can be achieved with nVidia cards, as there do not exist drivers with 3D
 +
acceleration for Ati cards on Solaris. Intel's chipsets should be fine too.
 +
All the above is for Solaris10/SXCE/SXDE. Opensolaris 2008.5 and .11 are both untested,
 +
but provided they contain all the developer tools, and the paths are set up correctly,
 +
Slicer should compile fine on it too.
 +
</pre>
  
 
== configuration options ==
 
== configuration options ==

Revision as of 20:25, 16 June 2009

Home < Slicer3:Build Instructions

All-in-one Script to checkout and build Slicer3

To compile and build Slicer3, you need a set of development packages installed on your machine:

There's a script called getbuildtest.tcl that makes the support libraries (VTK, ITK, teem, etc) and also builds slicer and does a dashboard submission. (Click here for background on getbuildtest and the experimental getbuildtest2 version).


Building the 3.4 release

Just do the following two commands (see for windows users below):

  svn co http://svn.slicer.org/Slicer3/branches/Slicer-3-4 Slicer3

  ./Slicer3/Scripts/getbuildtest.tcl

Building the 3.2 release

Just do the following two commands (see for windows users below):

  svn co http://svn.slicer.org/Slicer3/branches/Slicer-3-2 Slicer3

  ./Slicer3/Scripts/getbuildtest.tcl

Building the latest development version

  svn co http://svn.slicer.org/Slicer3/trunk Slicer3

  ./Slicer3/Scripts/getbuildtest.tcl

Note: that a Slicer3-lib and Slicer3-build directory will be created for you. This is meant to be used to set up new machines and to run nightly testing of the full builds.

To run (all platforms):

./Slicer3-build/Slicer3

Note: the whole build environment takes about 8G of disk space.

Testing

Note also that getbuildtest will do an Experimental submission to the Slicer3 dashboard. If you want to use getbuildtest without submitting to the dashboard, you can set the test type to nothing with

getbuildtest.tcl -t ""

Other options for the -t (--test-type) option are Nightly or Continuous (or any of the CTest options).

What does getbuildtest.tcl do?

This script just automates the steps needed to build slicer. What you end up with is a set of source and build directories that can either be further manipulated with getbuildtest or can be worked with normally. That is, on windows you will have solution files that you can load in visual studio for debugging and further development.

Specifically, getbuildtest does the following steps:

  • Refreshes Slicer3 svn
  • Runs Scripts/genlib.tcl which does the following for each of the support libraries
    • does a cvs/svn checkout/update
    • runs cmake with the correct settings for use with Slicer3
    • runs make (or developer studio) to build the libraries
  • Runs cmake on Slicer3
  • Builds Slicer3
  • Runs ctest on Slicer3
  • (optionally) Runs CPack on Slicer3

Usage

Usage:

 usage: getbuildtest [options] [target]
   [target] is determined automatically if not specified
   [options] is one of the following:
    --help : prints this message and exits
    --clean : delete lib and build directories first
    -t --test-type : CTest test target
    --release : compile with optimization flags
    --update : does a cvs/svn update on each lib
    --pack : builds a distribution package (cpack)

Errors from getbuildtest

You will need to have your firewall configured to allow access to cvs servers through port 2401. Also you need 8081 for submitting to the dashboard.

Other errors might mean you don't have all the build tools (see next section).

If you want to generate a log of the build process, you can use a command like the following:

# for csh/tcsh:
./Scripts/getbuildtest.tcl |& tee build.log

or

# for sh/bash:
./Scripts/getbuildtest.tcl 2>&1 | tee build.log

Updating Your getbuildtest Build

There are a few options:

  • you can re-run getbuildtest and it will update slicer3 and rebuild (just slicer3)
  • you can add the --update option and all the libs will get a cvs/svn update and will rebuild if needed (good for tracking the development head of VTK/ITK/KWWidgets etc).
  • you can just 'svn update' in the Slicer3 directory and then do 'make' in the Slicer3-build to get just the latest Slicer3 code.

The following command for unix machines will update, build, and launch the latest Slicer3:

svn update && (cd ../Slicer3-build; make && ./bin/Slicer3)

Note that on Windows you can also use the CMakeSetup.exe interface to CMake and then use Microsoft Visual Studio for debugging. You can use a command like the following in a cygwin shell to use the slicer launcher to start up visual studio with the correct environment to find the .dll files needed for debugging.

./Slicer3.exe --launch c:/Program\ Files/Microsoft\ Visual\ Studio\ 8/Common7/IDE/devenv.exe --detach Slicer3.sln

getbuildtest on linux

To compile Slicer3 and do development, be sure you have a complete set of development packages installed on your machine. The exact packages vary by distribution, but include:

  • gcc
  • gcc-c++
  • libX11
  • libX11-devel (libX11-dev on Ubuntu 7.04)
  • libXt-devel (libXt-dev on Ubuntu)
  • opengl/mesa (libgl1-mesa-dev on Ubuntu)

Ubuntu one line install:

sudo apt-get install subversion cvs tcl8.4 gcc g++ libX11-dev libXt-dev libxext-dev libgl1-mesa-dev libncurses5-dev tcsh

Also, be sure you have OpenGL and the GLX extension to X working. To check the installation, it is usually enough to confirm that the command

glxgears

runs with no errors.

getbuildtest on windows

The script should work fine on a properly configured windows environment. Current requirements are:

  • Developer Studio 8 2005
    • For Developer Studio 9.0 2008 Visual C++ Express which is free from Microsoft see below.
    • Be sure to install any service packs for Visual C++.
    • Older releases of visual studio are not tested and may not work (2003, 7, and 7.1)
    • If they are installed in the default locations in "c:/Program Files" they will be detected by the build script automatically (you need to edit slicer_variables.tcl to point to the installation).
  • Cygwin with the following packages
    • tcltk
    • svn
    • cvs
    • unzip
    • curl
  • With Developers Studio and cygwin installed, you only need to do the svn checkout and getbuildtest script to get a fully working Slicer3 plus all the tools you need to develop new code.

Note: CMake and VTK will not work on a FAT formatted disk (use NTFS).

getbuildtest on Apple Mac OS X

For Mac OS 10.4.10 install the following from the OS disks (not installed by default on new machines):

  • Xcode Tools (OS Disk 1, default window)
  • X11: also on OS Disk 1, but you need to scroll down and find the Optional Installs installer and select X11 under Applications. See step-by-step instructions.
  • X11SDK - from OS Disk 1, Xcode Tools/Packages/X11SDK.pkg
  • Subversion. Installation options here. Get the latest svn version for compatibility with the server and be sure your client includes SSL (so it can access https repositories).

Remember to run getbuildtest from an xterm so the tests can access the X server.

Note: The Apple X11 application on Mac OSX 10.5.x (Leopard) crashes frequently. We suggest you replace the default XX with XQuartz.

getbuildtest on Solaris

The notes on package requirement and build instructions were contributed by Attila Nagy.

Getbuildtest on Solaris

To build Slicer on Solaris, the best practice is to install the OS with Entire Distribution + OEM Support. 
This way all needed libraries and tools will be there. Solaris 10, Solaris eXpress Community Edition (SXCE), 
and Solaris eXpress Developer Edition (SXDE) 1/08 are all tested.

The needed packages are:
SUNWgcc SUNWgmake SUNWcvs SUNWsvn SUNWTcl SUNWxwplt SUNWxorg-mesa SUNWxorg
In case there are missing packages, yout can install them from the install CD/DVD. 
Put it in the drive, or mount the iso via lofi, and browse to the Solaris_10/Product 
(or Solaris_11/Product in case of SXCE/SXDE) directory, and
pkgadd -d . SUNWgcc SUNWgmake SUNWcvs SUNWsvn SUNWTcl SUNWxwplt SUNWxorg-mesa SUNWxorg

Make sure to put /usr/sfw/bin in your path, so the build tools find gcc/g++. Compilation 
with Sun's compilers (cc/CC) is not yet fully supported, but work is on the way.

If you need, you can install newer versions of the above tools either from blastwave, or 
from sunfreeware. In both cases check your paths! Put /opt/csw/bin in case of blastwave, 
and /usr/local/bin in case of sunfreeware in your profile, and replace "/usr/sfw/bin/g++" 
in Slicer3/slicer_variables.tcl with the updated paths.

You can check your 3D acceleration by running: /usr/X11/demo/glxgears
Best results can be achieved with nVidia cards, as there do not exist drivers with 3D 
acceleration for Ati cards on Solaris. Intel's chipsets should be fine too.
All the above is for Solaris10/SXCE/SXDE. Opensolaris 2008.5 and .11 are both untested, 
but provided they contain all the developer tools, and the paths are set up correctly, 
Slicer should compile fine on it too. 

configuration options

The file Slicer3/slicer_variables.tcl includes configuration options for which versions of support libraries to use. You may want to change these for testing or to get access to new functionality.

These flags control the versions of code pulled from external repositories:

set ::Slicer3_TAG "http://svn.slicer.org/Slicer3/trunk"
set ::CMAKE_TAG "CMake-2-6"
set ::KWWidgets_TAG "Slicer-3-2"
set ::VTK_TAG "VTK-5-2"
set ::ITK_TAG ITK-3-6
set ::PYTHON_TAG "http://svn.python.org/projects/python/branches/release25-maint"

Other libraries, such as Tcl/Tk, teem, and curl, together with windows binaries for CMake and Tcl/Tk are mirrored for efficiency at http://svn.slicer.org/Slicer3-lib-mirrors.

For example, you may want a build against the ITK cvs head. Change the flag value and then run

getbuildtest.tcl --update 

which will get the version from cvs, build it, and rebuild slicer3. Depending on how radically different the versions you build are, you may need to use the --clean option which will delete all build directories and rebuild.

Manual checkout/build of Slicer3 and support libraries:

Note: the getbuiltest script described above simply automates and systematizes a sequence of build operations that can be performed manually. You may want to use the manual method if you are testing against different versions of VTK or ITK, or if you have existing build trees that you want to re-use. Note that not all combinations of software versions and build flags are actively tested. The following information may not be up to date as new code is added to the various repositories.


Prerequisite software

You need to get and build the following packages if you aren't using the getbuildtest script. The tags for all of the versions we are currently using can be found in the file Slicer/slicer_variables.tcl, so if you are unsure, check there for the latest word on versions:

set ::CMAKE_TAG "CMake-2-6"
set ::Teem_TAG http://teem.svn.sourceforge.net/svnroot/teem/teem/trunk
set ::KWWidgets_TAG "HEAD"
set ::VTK_TAG "VTK-5-2"
set ::ITK_TAG ITK-3-8
set ::PYTHON_TAG "http://svn.python.org/projects/python/branches/release25-maint"
set ::BLAS_TAG http://svn.slicer.org/Slicer3-lib-mirrors/trunk/netlib/BLAS
set ::LAPACK_TAG http://svn.slicer.org/Slicer3-lib-mirrors/trunk/netlib/lapack-3.1.1
set ::NUMPY_TAG "http://svn.scipy.org/svn/numpy/branches/1.1.x"
set ::SCIPY_TAG "http://svn.scipy.org/svn/scipy/branches/0.6.x"
set ::SLICERLIBCURL_TAG "HEAD"
  1. CMake
  2. Tcl/Tk (8.4 or later)
  3. incrTcl (3.2.1)
  4. VTK
  5. ITK
  6. KWWidgets
  7. Teem
  8. SlicerLibCurl

Build Steps

Steps:

$ svn co http://svn.slicer.org/Slicer3/trunk Slicer3
$ cvs -d :pserver:anoncvs@www.vtk.org:/cvsroot/VTK co VTK -r VTK-5-2
$ cvs -d :pserver:anoncvs@www.itk.org:/cvsroot/Insight co Insight -r ITK-3-8
$ cvs -d :pserver:anoncvs@www.kwwidgets.org:/cvsroot/KWWidgets co KWWidgets
$ svn co http://svn.slicer.org/Slicer3-lib-mirrors/trunk/cmcurl cmcurl


Configure and build ITK

  • BUILD_SHARED_LIBS ON (optional)
  • CMAKE_SKIP_RPATH ON
  • ITK_USE_REVIEW ON
  • ITK_USE_OPTIMIZED_REGISTRATION_METHODS ON
  • ITK_USE_TRANSFORM_IO_FACTORIES ON

Configure and build VTK

  • All systems:
    • BUILD_SHARED_LIBS ON
    • CMAKE_SKIP_RPATH ON
    • VTK_WRAP_TCL ON
    • VTK_DEBUG_LEAKS ON


  • MacOSX specific (Make sure to install X11):
    • VTK_USE_CARBON OFF
    • VTK_USE_X ON


  • Note, those options should not appear, since they disapear since VTK5:
    • VTK_USE_HYBRID ON
    • VTK_USE_PATENTED ON
  • Make sure that the TCL and TK path are set properly
    • TCL_* and TK_*

Configure and build KWWidgets

  • You need to specify where your VTK build tree is.
  • BUILD_SHARED_LIBS ON
  • CMAKE_SKIP_RPATH ON

Configure and build curl

  • BUILD_SHARED_LIBS OFF

Build and Run Slicer3

Manually

  1. Check out and build slicer3 (e.g. on linux)
 svn co http://svn.slicer.org/Slicer3/trunk Slicer3
 mkdir Slicer3-build
 cd Slicer3-build
 ccmake ../Slicer3
 make

Again make sure to turn:

  • BUILD_SHARED_LIBS ON
  • CMAKE_SKIP_RPATH ON


Start slicer with the Slicer3 executable in your build directory.

SBuild

SBuild is a new, experimental build system for Slicer. It is based on getbuildtest2.tcl and genlib2.tcl, but rather than try to hid the gory details of building Slicer, SBuild attempts to expose a reasonable amount to the developer. The interface should be reasonably intuitive, but a brief walk through is useful. Click on the thumbnails for larger views. SBuild allows you to update and build just the portions of Slicer that you may require or want to build. Any of the required libraries may be specified to be build by SBuild, or to use an existing build. Existing libraries are not controlled by SBuild. Under the hood, SBuild calls CMake to do the heavy lifting, just like getbuildtest2.tcl.

Screenshots

SBuild screenshots
Main SBuild Window
Required libraries
SBuild configured for all external builds


  1. Configure the "Slicer Source Directory" by clicking on the "..." button, or typing a path to where you would like Slicer source saved
    1. Configure the "Slicer Build Directory" and "Slicer Library Directory" in the same fashion
  2. (Optional:) Switch to the "Required Libs" tab
    1. Configure any of the external builds that you may have by clicking on the checkbox next to the "Use external build" label
    2. When prompted, find the external build directory
    3. Note: SBuild looks for specific files inside the directory you choose, if not found you will be warned. In this case, choose better.
    4. Any of the required libraries may be Updated, Configured, or Built from this tab.
  3. To build everything, go to the Slicer3 tab and click "All"
    1. Output of the build process should fly by.

Binary downloads

Adding new Libraries to SBuild

The default package of SBuild contains the minimal number of required libraries to build Slicer. Currently no optional libraries are installed. The procedure for providing an SBuild plugin is modestly complicated, but several good examples exist. All plugins go in SBuild.vfs/lib/SBuildPlugins. As an example, let's create a plugin called Mythical, contained in SBuild.vfs/lib/SBuildPlugins/Mythical.tcl.

In the Slicer3/Scripts/SBuild directory, run ./bootstrap run to run SBuild, and ./bootstrap build to build the Tcl Starkits.

The first section of Mythical.tcl provides some housekeeping details:

package provide SBuildPlugins 1.0 

lappend ::SBuild(Plugins) Mythical 

set ::Plugin(Mythical,Type) "optional"
set ::Plugin(Mythical,Order) 100
set ::Plugin(Mythical,CanUseUserBuild) 1

The Mythical plugin must append itself to ::SBuild(Plugins) to register, and declares itself optional, builds in order 100, and can use user provided builds.

Each plugin must provide several Tcl procs to do various functions. The naming convention is PluginName-Function-Architecture. In this example PluginName is Mythical. SBuild first looks for the -Architecture variant, and failing, calls the PluginName-Function. For instance, Mythical-Update is the Tcl proc that updates the source for Mythical, while Mythical-Build-Windows is a specialization for Windows. The important functions are: Update, Configure, Build, and ConfigureSlicer. The ConfigureSlicer function may append a CMake argument to be used when Slicer is configured. If external packages are allowed, the ConfigureExternal function is called. ConfigureExternal usually looks for libraries and sets a LibPath to be used to configure Slicer. Examples of these functions are shown below.

# Here is where we would add lines to the main Slicer3 configuration
proc Mythical-Setup {} {
  global SBuild
}

# How do we setup for an external build
proc Mythical-ConfigureExternal {} {
  global SBuild
  set SBuild(Mythical,LibPath) [file dirname [FindFile $::SBuild(Mythical,ExternalBuildPath) [list libMythicalCommon* MythicalCommon*.lib MythicalCommon*.dll]]]
}

# Add a line to Slicer's CMake command
proc Mythical-ConfigureSlicer {} {
  global Plugin SBuild Slicer
  set dir [file join $SBuild(SlicerLibDir) Insight-build]
  if { $SBuild(Mythical,UseExternalBuild) } {
    set dir $SBuild(Mythical,ExternalBuildPath)
  }
  Debug "setting Mythical_DIR to $dir"
  lappend Slicer(CMakeArguments) -DMythical_DIR:FILEPATH=$dir
}

# How do we update Mythical?
proc Mythical-Update {} {
  Debug "Checking out Mythical"
  global SBuild Plugin
  file mkdir Insight
  ExecuteCommand $SBuild(SVNCommand) co http://www.mythical.org/svn/Mythical/trunk Mythical
}

# Configure to build
proc Mythical-Configure {} {
  Debug "Configure Mythical"
  global SBuild Plugin
  file mkdir Mythical-build
  cd Mythical-build
  ExecuteCommand $SBuild(CMake) \
    -G$SBuild(Generator) \
    -DCMAKE_CXX_COMPILER:STRING=$::SBuild(CompilerPath)/$SBuild(Compiler) \
    -DCMAKE_CXX_COMPILER_FULLPATH:FILEPATH=$::SBuild(CompilerPath)/$SBuild(Compiler) \
    -DBUILD_SHARED_LIBS:BOOL=ON \
    -DCMAKE_SKIP_RPATH:BOOL=ON \
    -DBUILD_EXAMPLES:BOOL=OFF \
    -DBUILD_TESTING:BOOL=OFF \
    -DCMAKE_BUILD_TYPE:STRING=$::SBuild(BuildType) \
    -DCMAKE_CXX_FLAGS_DEBUG:STRING=$::SBuild(CMakeCXXFlagsDebug) \
    ../Insight
}

# How do we build on windows?
proc Mythical-Build-Windows {} {
  global SBuild
  cd Insight-build
  ExecuteCommand $SBuild(Make) Mythical.SLN /build  $SBuild(BuildType)
}

# How do we build on other Makefile-based systems?
proc Mythical-Build {} {
  Debug "Building Mythical"
  global SBuild
  cd Insight-build
  eval ExecuteCommand $SBuild(Make) $SBuild(ParallelMake)
}

# Clean up Mythical (nothing for the moment).
proc Mythical-Clean {} {
  Debug "Cleaning Mythical"
}

Links

Information on Free Microsoft C++ Compiler on Windows

To build with the free version of the windows compiler, follow the instructions here.

As of April 11, 2008, this works with the slicer3 svn trunk. You will need to manually install a newer version of cmake as part of the process described in the link above.