Difference between revisions of "Slicer3:Build Instructions"

From NAMIC Wiki
Jump to: navigation, search
m (Text replacement - "http://www.slicer.org/slicerWiki/index.php/" to "https://www.slicer.org/wiki/")
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= All-in-one Script to checkout and build Slicer3 =
+
<big>'''Note:''' We are migrating this content to the slicer.org domain - <font color="orange">The newer page is [https://www.slicer.org/wiki/Slicer3:Build_Instructions here]</font></big>
 
 
To compile and build Slicer3, you need a set of development packages installed on your machine:
 
* [http://www.na-mic.org/Wiki/index.php/Slicer3:Build_Instructions#getbuildtest_on_linux pre-requisite material for Linux ]
 
* [http://www.na-mic.org/Wiki/index.php/Slicer3:Build_Instructions#getbuildtest_on_windows pre-requisite material for Windows ]
 
* [http://www.na-mic.org/Wiki/index.php/Slicer3:Build_Instructions#getbuildtest_on_Apple_Mac_OS_X pre-requisite material for 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).
 
 
 
Just do the following two commands (see [[Slicer3:Build_Instructions#getbuildtest_on_windows|for windows users]] below):
 
 
 
 
  svn co http://www.na-mic.org/svn/Slicer3/trunk Slicer3
 
 
  ./Slicer3/Scripts/getbuildtest.tcl
 
 
 
<br /> 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 2G of disk space.
 
 
 
== Testing ==
 
 
 
Note also that getbuildtest will do an Experimental submission to the [http://www.na-mic.org/Slicer3/Dashboard/ 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 [http://www.cmake.org/Wiki/CMake_Testing_With_CTest 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 na-mic.org for cvs access 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)
 
 
 
<br />
 
 
 
== getbuildtest on linux ==
 
 
 
To compile slicer 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 <pre>glxgears</pre> runs with no errors.
 
 
 
== getbuildtest on windows ==
 
 
 
The script should work fine on a properly configured windows environment. Current requirements are:
 
 
 
* Developer Studio 8 Visual C++ Express which is free from Microsoft - be sure to install the Platform SDK and follow the ridiculous manual steps to set up the paths [[Slicer3:Build_Instructions#Information_on_Free_Microsoft_C.2B.2B_Compiler_on_Windows|see below]].
 
* Developer Studio 9 Visual C++ Express [[Slicer:Build_Instructions:MSVS9]]
 
** Other releases of visual studio also work (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).
 
 
 
== 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 [http://porting.openoffice.org/mac/faq/installing/X11.html step-by-step instructions].
 
* X11SDK - from OS Disk 1, Xcode Tools/Packages/X11SDK.pkg
 
* Subversion.  Installation [http://downloads.open.collab.net/binaries.html 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.
 
 
 
== configuration options ==
 
 
 
The file Slicer3/slicer_variables.tcl includes configuration options for which support libraries to use.  You may want to change thes for testing or to get access to new functionality. 
 
 
 
set ::SLICER_TAG "http://www.na-mic.org/svn/Slicer3/trunk"
 
set ::CMAKE_TAG "CMake-2-4-2"
 
set ::TEEM_TAG "Teem-1-9-0-patches"
 
set ::KWWidgets_TAG "HEAD"
 
set ::VTK_TAG "VTK-5-0"
 
set ::ITK_TAG ITK-3-0
 
set ::TCL_TAG "core-8-4-6"
 
set ::TK_TAG "core-8-4-6"
 
set ::ITCL_TAG "itcl-3-2-1"
 
set ::IWIDGETS_TAG "iwidgets-4-0-1"
 
set ::BLT_TAG "blt24z"
 
set ::SANDBOX_TAG "http://svn.na-mic.org/svn/NAMICSandBox/branches/Slicer-2-6"
 
set ::SLICERLIBCURL_TAG "HEAD"
 
 
 
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 --clean.
 
 
 
Another useful option is to change your build type to include support debugging.
 
 
 
set ::VTK_BUILD_TYPE "RelWithDebInfo"
 
 
 
options are Debug, Release, or RelWithDebInfo.  RelWithDebInfo is a compromise between speed and debuggability.  If you are tracking down a tough C++ bug you will get better information in Debug mode.  After changing this flag, you should run
 
 
 
getbuildtest.tcl --clean
 
 
 
to create a completely new build.
 
 
 
= Manual checkout/build of Slicer3 and support libraries: =
 
 
 
== Prerequisite software ==
 
 
 
You need to get and build the following packages if you aren't using the getbuildtest script:
 
 
 
# [http://www.cmake.org CMake (2.4.1 or later)]
 
# [http://www.tcl.tk Tcl/Tk (8.4 or later)]
 
# [http://sourceforge.net/projects/incrtcl/ incrTcl (3.2.1)]
 
# [http://www.vtk.org VTK 5.0]
 
# [http://www.itk.org ITK 3.4]
 
# [http://www.kwwidgets.org KWWidgets Slicer-3-0 tag]
 
# [http://teem.sf.net Teem (1.9.0)]
 
# [http://www.na-mic.org/svn/Slicer3-lib-mirrors/trunk/cmcurl/ SlicerLibCurl (HEAD tag)]
 
 
 
== Build Steps ==
 
 
 
Steps:
 
 
 
$ svn co http://www.na-mic.org/svn/Slicer3/trunk Slicer3
 
$ cvs -d :pserver:anoncvs@www.vtk.org:/cvsroot/VTK co VTK -r VTK-5-0
 
  $ cvs -d :pserver:anoncvs@www.itk.org:/cvsroot/Insight co Insight -r ITK-3-4
 
$ cvs -d :pserver:anoncvs@www.kwwidgets.org:/cvsroot/KWWidgets co KWWidgets -r Slicer-3-0
 
$ svn co http://www.na-mic.org/svn/Slicer3-lib-mirrors/trunk/cmcurl cmcurl
 
 
 
 
 
=== Configure and build ITK ===
 
 
 
* BUILD_SHARED_LIBS ON
 
* CMAKE_SKIP_RPATH ON
 
 
 
=== Configure and build VTK ===
 
 
 
* All systems:
 
** BUILD_SHARED_LIBS ON
 
** CMAKE_SKIP_RPATH ON
 
** VTK_WRAP_TCL ON
 
** VTK_DEBUG_LEAKS ON
 
 
 
<br />
 
 
 
* MacOSX specific (Make sure to install [http://www.apple.com/downloads/macosx/apple/x11formacosx.html X11]):
 
** VTK_USE_CARBON OFF
 
** VTK_USE_X ON
 
 
 
<br />
 
 
 
* 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 ===
 
 
 
# Check out and build slicer3 (e.g. on linux)
 
 
 
  svn co http://www.na-mic.org/svn/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 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 =
 
 
 
* http://www.na-mic.org/Wiki/index.php/Slicer3
 
* http://www.na-mic.org/websvn/listing.php?repname=Slicer3
 
* [[Slicer3::Eclipse | Howto integrate Slicer3 into Eclipse]]
 
== Information on Free Microsoft C++ Compiler on Windows ==
 
 
 
Be sure to follow '''all''' the steps on Microsoft link. Yes it means you need to download the compiler '''and''' sdk.
 
 
 
* http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/
 

Latest revision as of 18:07, 10 July 2017

Home < Slicer3:Build Instructions

Note: We are migrating this content to the slicer.org domain - The newer page is here