This section details how to build your own development version of Slicer. You can also use it if you wish to run a version from the CVS repository. It details what support libraries that you need to install first, how to get the Slicer code from CVS, and how to build it all.
These instructions were originally written for UNIX/Linux machines. Windows requires a similar setup if you are using cygwin, which provides a UNIX-like command prompt.
The build process that the developers use assumes that third-party sources (Tcl and VTK) are built in subdirectories of slicer2/Lib/[osname]
. This procedure assumes that arrangement.
You can also refer to the alternate instructions for Building Slicer 2.4 if you wish to build the release from sources.
You need some software on your machine before starting.
If you check out the Slicer code from CVS first, you can run the tcl script found in slicer2/Scripts/genlib.tcl
and it will build the support software for you (assuming you have a compiler and a cvs client available).
g++
http://gcc.gnu.org/. cvs
cygwin
. You can download it from http://sources.redhat.com/cygwin/. Install everything on the options list, if possible, but be sure to get cvs
.
cmake
CMakeSetup.exe
.
cmake
and g++
(due to compiler compatibility issues with g++
that will arise when compiling VTK). But for Windows, you can probably just get the binary release.slicer2/Lib/[osname]/ActiveTcl-[version]
for
installation of the precompiled files.
slicer2/Lib/[osname]/gsl
for the installation of the precompiled files.
slicer2/Lib/[osname]/vtk/VTK-[version]
and build it using cmake
, instructing it to place the resulting binaries into slicer2/Lib/[osname]/vtk/VTK-build
. Valid osname
values (so they match up when you compile Slicer) are currently solaris8
, linux-x86
, darwin-ppc
, and win32
.cmake
on UNIX, or CMakeSetup.exe
on Windows, make sure that you configure it with tcl, tkwidget, patented, local, shared, hybrid. Make sure WRAP_TCL
and VTK_USE_HYBRID
are set to ON
. You will need to point it to the version of Tcl that you downloaded. Consult the VTK documentation in the root source code directory.
vtkITK
module (if you don't want to use it, you can delete the Modules/vtkITK
directory), you need to obtain ITK (Insight Toolkit). It can be download from www.itk.org .
On Solaris especially, you must build VTK (and ITK) against the same version of Tcl that you will be
using to run Slicer. Tcl, VTK, and Slicer must all be compiled with the same compiler.
For Windows, chances are good that the precompiled binaries were compiled with Microsoft Visual Studio, though there may be version issues.
The classes that Slicer adds to VTK are found in the directory
slicer2/Base/cxx
.
xterm
or a cygwin
window, do the following:
The password for the anonymous (read only) account iscvs -d :pserver:anonymous@cvs.spl.harvard.edu:/projects/cvs/slicer login
cvs -d :pserver:anonymous@cvs.spl.harvard.edu:/projects/cvs/slicer checkout slicer2
bwhspl
. Replace anonymous with your user name if you have a CVS account.cygwin
, you have problems logging into the CVS server because your cvspass
file couldn't be found, set your HOME
variable to the path to your cygwin home directory and
use the tcsh
shell instead of bash
.
Make a sub directory in the slicer2/Base/builds
directory named for your operating system: solaris8
, redhat7.3
, Win32VC7
are the current valid operating system values. If you change this, you will need to edit slicer2/slicer_variables.tcl
to reset your operating system version. At run time, the launcher will look in the subdirectory for the operating system on which you are running the program in order to load the library files.
Then point cmake
or CMakeSetup.exe
to slicer2/Base
as the source and your new builds
directory as the
destination, and point it to your vtk4.x
build and you should be ready
to compile.
slicer2/Scripts/cmaker.tcl
contains the commands to set up cmake
and then start the compilation after cmake
generates your make files. cmaker.tcl
sources the slicer2/slicer
_variables.tcl
file, which sets up the environment variables needed for the compilation (and run) step.
slicer_variables.tcl
with your favourite text editor and set the variables for your platform. The variables that need to be set are at the bottom of the file, switched on the operating system. SLICER_HOME
is set automatically from the directory that the slicer_variables.tcl
file is in. At the SPL, under SunOS, we use:
For Windows, you will need to point theset VTK_DIR /projects/birn/slicer2/Lib/solaris8/vtk/VTK-build-[version]
set VTK_SRC_DIR /projects/birn/slicer2/Lib/solaris8/vtk/VTK-[version]
set ITK_BINARY_PATH /projects/birn/itk/itk-1.2/itk-build
set COMPILER_PATH "/local/os/bin" set COMPILER "g++"
COMPILER
variable to the MS Visual Studio compiler, cl.exe
. Slicer will pick up the Tcl settings from VTK.Then execute:
This will configure and build the Slicer core against the version of VTK that you supplied. It will also compile the distributed Modules in theslicer2/Scripts/cmaker.tcl
slicer2/Modules
subdirectory and any others that you specify (see Adding a Module for more details). Slicer inherits CMake
settings from VTK, which inherits some CMake
settings from Tcl, which is why all three must be compiled with the same compiler.
NOTE: Replacecd slicer2/Base/builds
mkdir [my-os]
cd slicer2/Base/builds/[my-os]
ccmake -i ../../
[my-os]
with the name and version of your operating system, for example, solaris8
or redhat7.3
or Win32VC7
.ccmake
to either the installed or the built versions of VTK, as you would have set above while editing slicer_variables.tcl
. You must point to the proper tcl library, following the example from the SPL system:
TCL_LIBRARY
to -L/projects/birn/slicer2/Lib/solaris8/ActiveTcl8.4.2.0-solaris-sparc/lib -ltcl8.4
TCL_INCLUDE_PATH
to /projects/birn/slicer2/Lib/solaris8/ActiveTcl8.4.2.0-solaris-sparc/include
Make sure WRAP_TCL
is set to ON
, and you are configured to use tkwidget, patented, local, shared, hybrid.
Once you're happy with your settings, you will need to type c to configure (repeat until all fields are filled in) and then g to generate make files.
ccmake
writes a file called CMakeCache.txt
. If you have errors using
ccmake
or compiling you may wish to edit that file directly, and
then simply run cmake
, which will read the file. However, it is
often better to erase all subdirectories and start again.
Then run make
in the slicer2/Base/builds/[my-os]
directory. Repeat for any modules that you wish to build, starting in slicer2/Base/vtkCustomModule
if you wish a practice directory.
slicer2/slicer_variables.tcl
to reflect your local setup. Make sure that the environment variables VTK_DIR
, ITK_BINARY_PATH
, TCL_BIN_DIR
, and TCL_LIB_DIR
are pointing at the right directories. If you installed the support packages in slicer2/Lib
or built them using the genlib.tcl script, you shouldn't need to make any changes.
The slicer2/slicer2-[os]-[arch]
executables from cvs
will read in launch.tcl
and bootstrap Slicer. (NOTE: There is no need to run Scripts/make-launchers.tcl
since most of
the launch process is now in launch.tcl
and cvs
has the pre-made launchers.) Execute the file labeled for your operating system to start Slicer.
VTK_DATA_ROOT
to point to where you installed it.launch.tcl
script will accept a path to a Tcl script to execute, instead of the Slicer user interface. You can call it via:
You can also run the tests from VTK. Set the following environment variables appropriately, as they are set automatically in thecd ${SLICER_HOME}/Base/tests
../../slicer-[os]-[arch] ./TestImageCloseUp2D.tcl
slicer2
launching script, but we by-pass that script for the test:
To runSLICER_HOME /path_to_slicer2/slicer2
TCL_LIBRARY /path_to_lib/tcl8.4
TK_LIBRARY /path_to_lib/tk8.4
VTK_DATA_ROOT /projects/VTKData/
LD_LIBRARY_PATH ${SLICER_HOME}/Base/builds/[my-os]/bin:${LD_LIBRARY_PATH}
TCLLIBPATH "${SLICER_HOME}/Base/Wrapping/Tcl/vtkSlicerBase /usr/local/src/vtk4/VTK/Wrapping/Tcl"
TestImageCloseUp2D.tcl
, for example, do the following:
cd ${SLICER_HOME}/Base/tests
vtk TestImageCloseUp2D.tcl