Difference between revisions of "Slicer3:Build Instructions"

From Slicer Wiki
Jump to: navigation, search
m (Text replacement - "\[http:\/\/www\.slicer\.org\/slicerWiki\/index\.php\/([^ ]+) ([^]]+)]" to "$2")
 
(71 intermediate revisions by 12 users not shown)
Line 2: Line 2:
  
 
To compile and build Slicer3, you need a set of development packages installed on your machine:  
 
To compile and build Slicer3, you need a set of development packages installed on your machine:  
* [[Slicer3:Build_Instructions#getbuildtest_on_linux| pre-requisite material for Linux]]
+
 
* [[Slicer3:Build_Instructions#getbuildtest_on_windows| pre-requisite material for Windows]]
+
Pre-requisite material:
* [[Slicer3:Build_Instructions#getbuildtest_on_Apple_Mac_OS_X |pre-requisite material for Mac]]
+
* [[Slicer3:Build_Instructions#getbuildtest_on_linux| Linux]]
 +
* [[Slicer3:Build_Instructions#getbuildtest_on_Windows|Windows]]
 +
* [[Slicer3:Build_Instructions#getbuildtest_on_Apple_Mac_OS_X |Mac]]
  
 
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 [[Slicer3:getbuildtest | here for background on getbuildtest]] and the experimental getbuildtest2 version).
 
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 [[Slicer3:getbuildtest | here for background on getbuildtest]] and the experimental getbuildtest2 version).
  
 +
= Building the 3.6 release =
 +
For Linux and Mac, just do the following two commands. If you are a Windows user, you need to [[Slicer3:Build_Instructions_Windows#Open_cygwin_terminal_window | open a cygwin terminal window]] and type the commands in that window.
  
== Building the 3.4 release ==
+
   svn co http://svn.slicer.org/Slicer3/branches/Slicer-3-6 Slicer3
 
 
Just do the following two commands (see [[Slicer3:Build_Instructions#getbuildtest_on_windows|for windows users]] below):
 
 
 
   svn co http://svn.slicer.org/Slicer3/branches/Slicer-3-4 Slicer3
 
 
   
 
   
 
   ./Slicer3/Scripts/getbuildtest.tcl
 
   ./Slicer3/Scripts/getbuildtest.tcl
  
== Building the 3.2 release ==
+
For Slicer 3.4 build instructions, please see
 
+
[http://www.slicer.org/slicerWiki/index.php?title=Slicer3:Build_Instructions&oldid=14059#Building_the_3.4_release|a previous version of this page].
Just do the following two commands (see [[Slicer3:Build_Instructions#getbuildtest_on_windows|for windows users]] below):
 
  
  svn co http://svn.slicer.org/Slicer3/branches/Slicer-3-2 Slicer3
+
Note that as of August 12, 2011 the Slicer3 trunk requires [http://gitscm.com '''git'''] to build (in addition to cvs and svn and other dependencies listed below).
 
  ./Slicer3/Scripts/getbuildtest.tcl
 
  
== Building the latest development version ==
+
= Building the latest development version =
  
 
   svn co http://svn.slicer.org/Slicer3/trunk Slicer3
 
   svn co http://svn.slicer.org/Slicer3/trunk Slicer3
Line 33: Line 30:
 
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.
 
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):
+
Note: the trunk and 3.6 branches are copies of each other.  So there (should be/is) no difference between the two methods described above.  See Steve's email (link below) for more information.
 +
 
 +
http://massmail.spl.harvard.edu/public-archives/slicer-devel/2010/005338.html
 +
 
 +
= To run (all platforms): =
  
 
  ./Slicer3-build/Slicer3
 
  ./Slicer3-build/Slicer3
  
 
Note: the whole build environment takes about 8G of disk space.
 
Note: the whole build environment takes about 8G of disk space.
 +
 +
= Additional Information About getbuildtest and Building Slicer =
  
 
== Testing ==
 
== Testing ==
Line 64: Line 67:
  
 
== Usage ==
 
== Usage ==
 
+
Usage: getbuildtest [options] [target]
Usage:
+
  [target] is determined automatically if not specified
 
+
  [options] is one of the following:
  usage: getbuildtest [options] [target]
+
  h --help : prints this message and exits
    [target] is determined automatically if not specified
+
  -f --clean : delete lib and build directories first
    [options] is one of the following:
+
  -t --test-type : CTest test target (default: Experimental)
    --help : prints this message and exits
+
  --release : compile with optimization flags
    --clean : delete lib and build directories first
+
  --relwithdebinfo : compile with optimization flags and debugging symbols
    -t --test-type : CTest test target
+
  -u --update : does a cvs/svn update on each lib
    --release : compile with optimization flags
+
  --no-slicer-update : don't update slicer source (does not effect libs)
    --update : does a cvs/svn update on each lib
+
  --build-dir : override default build directory
    --pack : builds a distribution package (cpack)
+
  --doc-dir : override default documentation directory
 +
  --version-patch : set the patch string for the build (used by installer)
 +
                  : default: version-patch is the current date
 +
  --tag : same as version-patch
 +
  --pack : run cpack after building (default: off)
 +
  --pack-dir : where to copy the package after build
 +
  --upload : set the upload string for the binary, used if pack is true
 +
            : snapshot (default), nightly, release
 +
  --doxy : just do an svn update on Slicer3 and run doxygen
 +
  --verbose : optional, print out lots of stuff, for debugging
 +
  --rpm : optional, specify CPack RPM generator for packaging
 +
  --deb : optional, specify CPack DEB generator for packaging
 +
  -e --extend : optional, build external modules using the extend script
 +
  -32 -64 : Set if we want to build Slicer 32 or 64 bits
 +
            : The default on Solaris is the current bitness of the underlying kernel (isainfo -b)
 +
            : The default on Linux is the current bitness of the underlying kernel
 +
            : 32 bits on other platforms
 +
  --gcc --suncc : Set the desired compiler for the build process
 +
            : The default is gcc/g++
  
 
== Errors from getbuildtest ==
 
== Errors from getbuildtest ==
Line 90: Line 111:
 
  # for sh/bash:
 
  # for sh/bash:
 
  ./Scripts/getbuildtest.tcl 2>&1 | tee build.log
 
  ./Scripts/getbuildtest.tcl 2>&1 | tee build.log
 +
 +
'''Windows:''' visual studio build messages do not go to stdout/stderr, but each build directory in  Slicer3-lib will have a buildlog.txt file with the details.
 +
 +
== Debugging ==
 +
 +
Since slicer relies on shared libraries, the correct paths must be set up before the debugger can operate (this is accomplished with the [[Slicer3:Launcher|Slicer3 Launcher]] which is in the top level of Slicer3-build).  The actual executable entry point (which should not be invoked directly by users) is ''Slicer3-build/bin/Slicer3-real''.  The following steps create a shell that has the proper paths set up:
 +
./Slicer3 --launch xterm &
 +
Inside the newly launched window, you can run:
 +
./bin/Slicer3-real
 +
or you can run the debugger of your choice in the new window. 
 +
 +
On windows (with rxvt installed via cygwin) the commands are:
 +
./Slicer3 --launch rxvt &
 +
and
 +
./bin/Debug/Slicer3-real.exe
 +
 +
 +
Other tools, such as performance analyzers, memory checkers, etc can also be used in the subshell.  Using the launcher is a convenient way to set up the paths for the local build without needing to set any library paths on a system-wide basis.  Note that this allows you to have several slicer builds in different directories without having them interfere with one another.  The slicer launcher should also allow you to run slicer with it's own local path settings even if you have globally installed versions of VTK, ITK, tcl, python, etc.
 +
 +
More information is available at the links below:
 +
 +
* For information on using the launcher to debug with gdb, see: [http://www.na-mic.org/Wiki/index.php/Slicer3_Q&A_2008-11-18#Debugging]
 +
* For debugging with Visual Studio, see: [http://www.na-mic.org/Wiki/index.php/User:Pieper#Launching_visual_studio_for_slicer3_debugging]
 +
* For debugging command line modules, see [[Slicer3:Execution_Model_Documentation:Debugging]
 +
 +
Note|you can also debug in XCode with similar methods, but you may need to manually copy the DYLD_LIBRARY_PATH into the project properties (XCode does not seem to inherit from its parent shell).
  
 
== Updating Your getbuildtest Build ==
 
== Updating Your getbuildtest Build ==
Line 116: Line 163:
 
* libXt-devel (libXt-dev on Ubuntu)
 
* libXt-devel (libXt-dev on Ubuntu)
 
* opengl/mesa (libgl1-mesa-dev on Ubuntu)
 
* opengl/mesa (libgl1-mesa-dev on Ubuntu)
 +
* glu (libglu1-mesa-dev on Ubuntu)
 +
* tcl
 +
  
 
Ubuntu one line install:
 
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
+
  sudo apt-get install subversion cvs tcl8.4 gcc g++ libX11-dev libXt-dev libxext-dev libgl1-mesa-dev libglu1-mesa-dev libncurses5-dev tcsh git-core
 +
 
 +
For Ubuntu 11.04 you also need to install libosmesa6-dev with:
 +
 
 +
sudo apt-get install libosmesa6-dev
 +
 
 +
For Ubuntu 12.04 you also need to install:
 +
 
 +
sudo apt-get install make
 +
 
 +
 
 +
CentOS 5.5 (Red Hat) one line install:
 +
yum install subversion cvs gcc-c++ libX11-devel libXt-devel make
 +
 
 +
You also need git for Centos but it isn't in the standard yum install.  One option is to install it using the instructions [http://www.webtatic.com/news/2011/05/latest-updates-git-1-7-5-1-httpd-itk-2-2-18/ here]].
 +
 
 +
Fedora 13 required packages as reported by John Drozd:
 +
 
 +
<pre>
 +
mesa-demos.i686                          7.8.2-1.fc13                  updates
 +
mesa-dri-drivers-experimental.i686      7.8.2-1.fc13                  updates
 +
mesa-libGL-devel.i686                    7.8.2-1.fc13                  updates
 +
mesa-libGLU-devel.i686                  7.8.2-1.fc13                  updates
 +
mesa-libGLw.i686                        6.5.1-8.fc12                  fedora 
 +
mesa-libGLw-devel.i686                  6.5.1-8.fc12                  fedora 
 +
mesa-libOSMesa.i686                      7.8.2-1.fc13                  updates
 +
mesa-libOSMesa-devel.i686                7.8.2-1.fc13                  updates
 +
</pre>
  
 
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 <pre>glxgears</pre> runs with no errors.
 
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 <pre>glxgears</pre> runs with no errors.
  
== getbuildtest on windows ==
+
On occasion, you will encounter a build error relating to the loading of the shared libraries libsvn_fs_util-1.so.0, which are required for the numpy build process. This is due to having a subversion 1.4 or lower installed on your machine. Since this is an optional build in Slicer, you can try building Slicer using these alternatives:
 +
*Turning off python support in the build settings (USE_PYTHON set to "OFF")
 +
*Set the USE_SYSTEM_PYTHON to "true"
  
The script should work fine on a properly configured windows environment. Current requirements are:
+
As of December 2011, Ubuntu 11.11 requires use of the Slicer3 trunk, not the Slicer-3-6 release branch.
  
* Developer Studio 8 2005
+
== getbuildtest on Windows ==
** For Developer Studio 9.0 2008 Visual C++ Express which is free from Microsoft [[Slicer3:Build_Instructions#Information_on_Free_Microsoft_C.2B.2B_Compiler_on_Windows|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).
 
* [http://www.cygwin.com 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).
+
The script should work when run from a [[Slicer3:Build_Instructions_Windows#Open_cygwin_terminal_window | cygwin terminal window]] on a properly configured windows environment.
 +
 
 +
Current requirements are:
 +
* Windows XP, Windows Vista, or Windows 7 operating system (note: ''Python is disabled by default for non-XP builds due to compilation issues'')
 +
* Fast network connection, no firewalls blocking outbound connections (cvs and svn will connect to servers to get source code)
 +
* The build directory shall be on an NTFS formatted disk (CMake and VTK will not work on a FAT formatted disk), with about About 10GB free disk space
 +
* Microsoft Visual Studio with Visual C++ compiler installed
 +
** Install all available service packs for Visual C++
 +
** If they are installed in the default locations in "c:/Program Files" they will be detected by the build script automatically (if they are not installed in the default location or you have multiple compiler versions installed, then you may need to edit slicer_variables.tcl to set the compiler installation path).
 +
** Compiler version:
 +
*** Developer Studio 9.0 2008 Visual C++ - this compiler is used to build Slicer3.5 development releases, there are no known limitations
 +
*** Developer Studio 9.0 2008 Visual C++ Express (the free version from Microsoft) - [[Slicer3:Build_Instructions_Windows#Installing_Microsoft_Visual_Studio_Express | see detailed installation instructions here]].
 +
**** Python will be disabled (only Visual Studio 2008 compiler supported by python 2.6).
 +
*** Developer Studio 8.0 2005 Visual C++ - it can be used to build Slicer3.5 with the following limitations
 +
**** Python will be disabled (only Visual Studio 2008 compiler supported by python 2.6).
 +
**** The compiler randomly crashes during the build (there is no known fix for this problem, just a workround: in case of a crash restart the build)
 +
*** Developer Studio 7.1 2003 and older - not tested and may not work
 +
* [http://www.cygwin.com Cygwin] installed - [[Slicer3:Build_Instructions_Windows#Installing_Cygwin | see detailed installation instructions here]]
 +
* [http://nsis.sourceforge.net/Download NSIS] installed (needed for installation package generation)
 +
* '''Windows 7''' - if you experience random failures during the build process, replace Slicer3-lib/CMake-build with the contents of this zip file: http://www.cmake.org/files/dev/cmake-2.8.1.20100603-g3d1e8-win32-.zip to address these issues with earlier cmake versions: http://public.kitware.com/Bug/view.php?id=10790 and http://public.kitware.com/Bug/view.php?id=10793
 +
* Be sure your visual studio version is fully patched (or random crashes may occur).
 +
* Slicer3 is tested on the English language version of windows.  Other languages may cause lead to mysterious build errors.  For example, Chinese language for non-Unicode programs (system locale) in Window 7 is known to have problems with KWWidgets.
 +
* Be sure your environment variables for TEMP and TMP are ''writable by your user account''.  If the temp variables point, for example, to c:/windows/TEMP then non-administrator account cannot write to it and some build steps will fail.  The correct temp paths appear to be: %USERPROFILE%\AppData\Local\Temp for windows 7.  Another option is to launch your cygwin shell using the Run As Administrator option.
 +
 
 +
Follow this link for [[Slicer3:Build_Instructions_Windows#Troubleshooting | common errors and troubleshooting on windows]].
  
 
== getbuildtest on Apple Mac OS X ==
 
== getbuildtest on Apple Mac OS X ==
Line 153: Line 245:
  
 
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].
 +
 +
If you come across the link error
 +
 +
  dyld: Library not loaded: libvtksys.5.6.dylib
 +
 +
Set the flag VTK_USE_RPATH=ON (see the post [http://vtk.1045678.n5.nabble.com/Compile-error-on-OS-X-10-5-td1245851.html here])
 +
 +
For the latest version of Mac OS X (10.7) the correct X11 comes pre-installed. 
 +
 +
As of December 2011, only Slicer3 trunk compiles on 10.7 (not the Slicer-3-6 branch).  Also python is not correctly compiled on 10.7 so it should be disabled by editing the Slicer3_USE_PYTHON option in slicer_variables.tcl
 +
 +
== getbuildtest on Solaris ==
 +
 +
Collaboration with the University of Szeged in Hungary has resulted in a port of slicer3 to the current generation of the Oracle (formerly Sun) Solaris operating system.  More information, including binary downloads, is available [[Slicer3:Solaris|at the Slicer3 Solaris page]].
  
 
== configuration options ==
 
== configuration options ==
Line 175: Line 281:
 
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.
 
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: =
+
== Changing version numbers ==
 
 
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"
 
 
 
# [http://www.cmake.org CMake]
 
# [http://www.tcl.tk Tcl/Tk (8.4 or later)]
 
# [http://sourceforge.net/projects/incrtcl/ incrTcl (3.2.1)]
 
# [http://www.vtk.org VTK]
 
# [http://www.itk.org ITK]
 
# [http://www.kwwidgets.org KWWidgets]
 
# [http://teem.sf.net Teem]
 
# [http://svn.slicer.org/Slicer3-lib-mirrors/trunk/cmcurl/ 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:
+
Click  [[Slicer3:ChangingVersionsCheckList | here]] for the checklist of things to do when branching svn and creating a new Slicer release.
** BUILD_SHARED_LIBS ON
 
** CMAKE_SKIP_RPATH ON
 
** VTK_WRAP_TCL ON
 
** VTK_DEBUG_LEAKS ON
 
  
<br />
+
= Building with Qt =
  
* MacOSX specific (Make sure to install [http://www.apple.com/downloads/macosx/apple/x11formacosx.html X11]):
+
If you start with an already built slicer, you can [[Qt_in_Slicer3#Building_Slicer_with_Qt| add Qt to the build]]. As of fall 2009 this is still very much a work in progress and the details are expected to change.
** VTK_USE_CARBON OFF
 
** VTK_USE_X ON
 
  
<br />
+
= Manual Build =
  
* Note, those options '''should not''' appear, since they disapear since VTK5:
+
You can also build Slicer without using getbuildtest.tcl. For more information about manually compiling Slicer, see [[Slicer3:Manual_Build|this page]].
** 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 ===
 
 
 
# 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
 
 
 
<br /> Start slicer with the Slicer3 executable in your build directory.
 
  
 
= SBuild =
 
= 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
 
|-
 
| [[image:SBuild-MainWindow.png|center|250px|Main SBuild Window]] || [[image:SBuild-RequiredWindow.png|center|250px|Required libraries]]
 
||[[image:SBuild-AllExternal.png|center|250px|SBuild configured for all external builds]] 
 
|}
 
 
 
# Configure the "Slicer Source Directory" by clicking on the "..." button, or typing a path to where you would like Slicer source saved
 
## Configure the "Slicer Build Directory" and "Slicer Library Directory" in the same fashion
 
# (Optional:) Switch to the "Required Libs" tab
 
## Configure any of the external builds that you may have by clicking on the checkbox next to the "Use external build" label
 
## When prompted, find the external build directory
 
## Note: SBuild looks for specific files inside the directory you choose, if not found you will be warned.  In this case, choose better.
 
## Any of the required libraries may be Updated, Configured, or Built from this tab.
 
# To build everything, go to the Slicer3 tab and click "All"
 
## Output of the build process should fly by.
 
 
== Binary downloads ==
 
 
* [[Media:SBuild-darwin-ppc.gz| Mac OSX PPC (must use X11)]]
 
* [[Media:SBuild-darwin-x86.gz| Mac OSX x86 (must use X11)]]
 
* [[Media:SBuild-linux-x86.gz| Linux x86]]
 
* [[Media:SBuild-linux-x86_64.gz| Linux x86-64]]
 
* [[Media:SBuild-win32_exe.gz| Win32 (please properly rename it)]]
 
* [[Media:SBuild.kit.gz| Generic tclkit (any platform)]]
 
 
== 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 =
 
* [[Main_Page| Slicer Wiki Pages]]
 
* [[Slicer3::Eclipse | Howto integrate Slicer3 into Eclipse]]
 
 
== Information on Free Microsoft C++ Compiler on Windows ==
 
To build with the free version of the windows compiler, follow the instructions [[Slicer3:Build_Instructions_Windows| here.]]
 
  
As of April 11, 2008, this works with the slicer3 svn trunkYou will need to manually install a newer version of cmake as part of the process described in the link above.
+
SBuild is a new, experimental build system for SlicerFor more information about SBuild, see [[Slicer3:SBuild|the SBuild page]].

Latest revision as of 02:29, 27 November 2019

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:

Pre-requisite material:

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.6 release

For Linux and Mac, just do the following two commands. If you are a Windows user, you need to open a cygwin terminal window and type the commands in that window.

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

  ./Slicer3/Scripts/getbuildtest.tcl

For Slicer 3.4 build instructions, please see previous version of this page.

Note that as of August 12, 2011 the Slicer3 trunk requires git to build (in addition to cvs and svn and other dependencies listed below).

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.

Note: the trunk and 3.6 branches are copies of each other. So there (should be/is) no difference between the two methods described above. See Steve's email (link below) for more information.

http://massmail.spl.harvard.edu/public-archives/slicer-devel/2010/005338.html

To run (all platforms):

./Slicer3-build/Slicer3

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

Additional Information About getbuildtest and Building Slicer

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: getbuildtest [options] [target]

 [target] is determined automatically if not specified
 [options] is one of the following:
  h --help : prints this message and exits
  -f --clean : delete lib and build directories first
  -t --test-type : CTest test target (default: Experimental)
  --release : compile with optimization flags
  --relwithdebinfo : compile with optimization flags and debugging symbols
  -u --update : does a cvs/svn update on each lib
  --no-slicer-update : don't update slicer source (does not effect libs)
  --build-dir : override default build directory
  --doc-dir : override default documentation directory
  --version-patch : set the patch string for the build (used by installer)
                  : default: version-patch is the current date
  --tag : same as version-patch
  --pack : run cpack after building (default: off)
  --pack-dir : where to copy the package after build
  --upload : set the upload string for the binary, used if pack is true
           : snapshot (default), nightly, release
  --doxy : just do an svn update on Slicer3 and run doxygen
  --verbose : optional, print out lots of stuff, for debugging
  --rpm : optional, specify CPack RPM generator for packaging
  --deb : optional, specify CPack DEB generator for packaging
  -e --extend : optional, build external modules using the extend script
  -32 -64 : Set if we want to build Slicer 32 or 64 bits
           : The default on Solaris is the current bitness of the underlying kernel (isainfo -b)
           : The default on Linux is the current bitness of the underlying kernel
           : 32 bits on other platforms
  --gcc --suncc : Set the desired compiler for the build process
           : The default is gcc/g++

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

Windows: visual studio build messages do not go to stdout/stderr, but each build directory in Slicer3-lib will have a buildlog.txt file with the details.

Debugging

Since slicer relies on shared libraries, the correct paths must be set up before the debugger can operate (this is accomplished with the Slicer3 Launcher which is in the top level of Slicer3-build). The actual executable entry point (which should not be invoked directly by users) is Slicer3-build/bin/Slicer3-real. The following steps create a shell that has the proper paths set up:

./Slicer3 --launch xterm &

Inside the newly launched window, you can run:

./bin/Slicer3-real

or you can run the debugger of your choice in the new window.

On windows (with rxvt installed via cygwin) the commands are:

./Slicer3 --launch rxvt &

and

./bin/Debug/Slicer3-real.exe


Other tools, such as performance analyzers, memory checkers, etc can also be used in the subshell. Using the launcher is a convenient way to set up the paths for the local build without needing to set any library paths on a system-wide basis. Note that this allows you to have several slicer builds in different directories without having them interfere with one another. The slicer launcher should also allow you to run slicer with it's own local path settings even if you have globally installed versions of VTK, ITK, tcl, python, etc.

More information is available at the links below:

  • For information on using the launcher to debug with gdb, see: [1]
  • For debugging with Visual Studio, see: [2]
  • For debugging command line modules, see [[Slicer3:Execution_Model_Documentation:Debugging]

Note|you can also debug in XCode with similar methods, but you may need to manually copy the DYLD_LIBRARY_PATH into the project properties (XCode does not seem to inherit from its parent shell).

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)
  • glu (libglu1-mesa-dev on Ubuntu)
  • tcl


Ubuntu one line install:

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

For Ubuntu 11.04 you also need to install libosmesa6-dev with:

sudo apt-get install libosmesa6-dev

For Ubuntu 12.04 you also need to install:

sudo apt-get install make


CentOS 5.5 (Red Hat) one line install:

yum install subversion cvs gcc-c++ libX11-devel libXt-devel make

You also need git for Centos but it isn't in the standard yum install. One option is to install it using the instructions here].

Fedora 13 required packages as reported by John Drozd:

mesa-demos.i686                          7.8.2-1.fc13                   updates 
mesa-dri-drivers-experimental.i686       7.8.2-1.fc13                   updates 
mesa-libGL-devel.i686                    7.8.2-1.fc13                   updates 
mesa-libGLU-devel.i686                   7.8.2-1.fc13                   updates 
mesa-libGLw.i686                         6.5.1-8.fc12                   fedora  
mesa-libGLw-devel.i686                   6.5.1-8.fc12                   fedora  
mesa-libOSMesa.i686                      7.8.2-1.fc13                   updates 
mesa-libOSMesa-devel.i686                7.8.2-1.fc13                   updates 

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.

On occasion, you will encounter a build error relating to the loading of the shared libraries libsvn_fs_util-1.so.0, which are required for the numpy build process. This is due to having a subversion 1.4 or lower installed on your machine. Since this is an optional build in Slicer, you can try building Slicer using these alternatives:

  • Turning off python support in the build settings (USE_PYTHON set to "OFF")
  • Set the USE_SYSTEM_PYTHON to "true"

As of December 2011, Ubuntu 11.11 requires use of the Slicer3 trunk, not the Slicer-3-6 release branch.

getbuildtest on Windows

The script should work when run from a cygwin terminal window on a properly configured windows environment.

Current requirements are:

  • Windows XP, Windows Vista, or Windows 7 operating system (note: Python is disabled by default for non-XP builds due to compilation issues)
  • Fast network connection, no firewalls blocking outbound connections (cvs and svn will connect to servers to get source code)
  • The build directory shall be on an NTFS formatted disk (CMake and VTK will not work on a FAT formatted disk), with about About 10GB free disk space
  • Microsoft Visual Studio with Visual C++ compiler installed
    • Install all available service packs for Visual C++
    • If they are installed in the default locations in "c:/Program Files" they will be detected by the build script automatically (if they are not installed in the default location or you have multiple compiler versions installed, then you may need to edit slicer_variables.tcl to set the compiler installation path).
    • Compiler version:
      • Developer Studio 9.0 2008 Visual C++ - this compiler is used to build Slicer3.5 development releases, there are no known limitations
      • Developer Studio 9.0 2008 Visual C++ Express (the free version from Microsoft) - see detailed installation instructions here.
        • Python will be disabled (only Visual Studio 2008 compiler supported by python 2.6).
      • Developer Studio 8.0 2005 Visual C++ - it can be used to build Slicer3.5 with the following limitations
        • Python will be disabled (only Visual Studio 2008 compiler supported by python 2.6).
        • The compiler randomly crashes during the build (there is no known fix for this problem, just a workround: in case of a crash restart the build)
      • Developer Studio 7.1 2003 and older - not tested and may not work
  • Cygwin installed - see detailed installation instructions here
  • NSIS installed (needed for installation package generation)
  • Windows 7 - if you experience random failures during the build process, replace Slicer3-lib/CMake-build with the contents of this zip file: http://www.cmake.org/files/dev/cmake-2.8.1.20100603-g3d1e8-win32-.zip to address these issues with earlier cmake versions: http://public.kitware.com/Bug/view.php?id=10790 and http://public.kitware.com/Bug/view.php?id=10793
  • Be sure your visual studio version is fully patched (or random crashes may occur).
  • Slicer3 is tested on the English language version of windows. Other languages may cause lead to mysterious build errors. For example, Chinese language for non-Unicode programs (system locale) in Window 7 is known to have problems with KWWidgets.
  • Be sure your environment variables for TEMP and TMP are writable by your user account. If the temp variables point, for example, to c:/windows/TEMP then non-administrator account cannot write to it and some build steps will fail. The correct temp paths appear to be: %USERPROFILE%\AppData\Local\Temp for windows 7. Another option is to launch your cygwin shell using the Run As Administrator option.

Follow this link for common errors and troubleshooting on windows.

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.

If you come across the link error

 dyld: Library not loaded: libvtksys.5.6.dylib

Set the flag VTK_USE_RPATH=ON (see the post here)

For the latest version of Mac OS X (10.7) the correct X11 comes pre-installed.

As of December 2011, only Slicer3 trunk compiles on 10.7 (not the Slicer-3-6 branch). Also python is not correctly compiled on 10.7 so it should be disabled by editing the Slicer3_USE_PYTHON option in slicer_variables.tcl

getbuildtest on Solaris

Collaboration with the University of Szeged in Hungary has resulted in a port of slicer3 to the current generation of the Oracle (formerly Sun) Solaris operating system. More information, including binary downloads, is available at the Slicer3 Solaris page.

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.

Changing version numbers

Click here for the checklist of things to do when branching svn and creating a new Slicer release.

Building with Qt

If you start with an already built slicer, you can add Qt to the build. As of fall 2009 this is still very much a work in progress and the details are expected to change.

Manual Build

You can also build Slicer without using getbuildtest.tcl. For more information about manually compiling Slicer, see this page.

SBuild

SBuild is a new, experimental build system for Slicer. For more information about SBuild, see the SBuild page.