For the latest Slicer developers documentation, visit the Nightly page.
- 1 PREREQUISITES
- 2 CHECKOUT slicer source files
- 3 CONFIGURE and generate Slicer solution files
- 4 BUILD Slicer
- 5 RUN Slicer
- 6 Common errors
- 6.1 CMake complains during configuration
- 6.2 A tool returned an error code from "Generating vtksysProcessFwd9xEnc.c"
- 6.3 error: ‘class QList<QString>’ has no member named ‘reserve’
- 6.4 libarchive.so: undefined reference to `SHA256_Update'
- 6.5 A tool returned an error code from "Performing configure step for ..."
- 6.6 A tool returned an error code from "Performing download step (git clone) for ..."
- 6.7 No rule to make target `/usr/lib/x86_64-linux-gnu/libGL.so'
- 6.8 X11 Window errors at start time
- 6.9 error C2061: syntax error : identifier 'ssize_t'
- 6.10 ld: framework not found QtWebKit
- 6.11 On MacOSX 10.8, CMake hangs forever
- 7 Quick Build on Debian
Please check that the following tools are installed on your machine.
|Qt libraries are required. Consider reading Qt requirements.|
|CMake is required.|
|Git is required.|
|SVN is required.|
Consider reading platform specific requirements listed below.
Ubuntu / Debian
For Ubuntu 13.04 note that you must download or install the standard cmake from  because the version of cmake that comes with Ubuntu 13.04 cannot be used to build slicer.
- Ubuntu, Debian squeeze, Debian testing (wheezy) users, just type the following line in a terminal
sudo apt-get install subversion git-core git-svn sudo apt-get install make gcc g++ libX11-dev libXt-dev libgl1-mesa-dev libosmesa6-dev libglu1-mesa-dev libfontconfig-dev libxrender-dev libncurses5-dev
mkdir ~/Support && cd Support # This is where we will download and install required software
# By copying this one-liner in your terminal, it will download and extract CMake cmake_package="cmake-188.8.131.52-Linux-i386"; \ wget http://www.cmake.org/files/v2.8/$cmake_package.tar.gz -v -O $cmake_package.tar.gz && \ tar -xzvf $cmake_package.tar.gz;
# By copying this one-liner, symbolic links to cmake tools will be created in /usr/local/bin. # That way calling cmake, ctest, ... from the command line will resolve to this version of CMake. for tool in cmake ccmake ctest cpack; do sudo ln -s ~/$cmake_package/bin/$tool /usr/local/bin/$tool; done
- CentOS user type:
yum install make gcc-c++ libX11-devel libXt-devel libXext-devel libGLU-devel mesa-libOSMesa-devel mesa-libGL-devel mesa-libGLU-devel ncurses
- Mac Os X >= 10.5 (Leopard)
- CMake >= 2.8.9
- For Mac Os X >= 10.8 (Mountain Lion) and/or recent XCode >= 4.5.X - CMake >= 2.8.11 is required. See http://www.cmake.org/files/v2.8/cmake-2.8.11-Darwin64-universal.tar.gz
$ curl -O http://www.cmake.org/files/v2.8/cmake-2.8.11-Darwin64-universal.tar.gz $ tar -xzvf cmake-2.8.11-Darwin64-universal.tar.gz --strip-components=1
$ CMake\ 2.8-11.app/Contents/bin/cmake --version cmake version 2.8.11
- Git >= 1.6.5
- XCode (for the SDK libs)
- Qt 4.7.4 or 4.8.4. See details here
- XQuartz - For Mac Os X >= 10.8 (Mountain Lion) install XQuartz (http://xquartz.macosforge.org) to get X11 (no longer a default in OS X).
- CMake >= 2.8.9
- Qt 4.7.4 or 4.8.4. See details here
- Git-X.X.X-preview2013XXXX.exe recommended.
- For convenience, you could update the PATH variable so that git can be automatically discovered when configuring Slicer. If not, you will have to specify the GIT_EXECUTABLE at configure time.
- NSIS (optional): Needed if packaging Slicer - Click here to download.
- Tested/Recommended: Microsoft Visual Studio 9 2008 (Any edition).
- Experimental: The plan is to support Microsoft Visual Studio 2010 (Any edition). NOTE THAT EXPERIMENTAL MEANS THIS DOESN'T YET WORK :)
- Experimental (Visual Studio 2012): Use a desktop version such as Visual Studio 2012 Express for Windows Desktop and remember Visual Studio 2012 Update 2). Do not use Visual Studio Express 2012 for Windows 8. You must install Windows SDK, otherwise CMake will not even find the C compiler during configure. In CMake, choose Visual Studio 11 Win64 as generator.
- Un-tested: Cygwin suite (building with cygwin gcc not supported, but the cygwin shell environment can be used to run git, svn, etc).
CHECKOUT slicer source files
Check out the code using
git and configure the
git svn bridge:
Clone the github repository
cd MyProjects git clone git://github.com/Slicer/Slicer.git
Slicerdirectory is automatically created after cloning Slicer.
Setup the development environment:
cd Slicer ./Utilities/SetupForDevelopment.sh
For more details see Development With Git.
git svnbridge to ensure the mapping with svn revision.
cd Slicer git svn init http://svn.slicer.org/Slicer4/trunk git update-ref refs/remotes/git-svn refs/remotes/origin/master git checkout master git svn rebase
CONFIGURE and generate Slicer solution files
You can configure and generate Slicer solution files using either
- Configure using default options.
- Set the build directory. For example:
- If you downloaded the Qt binary then
qmakewill be detected and all paths will be set automatically.
- If you built your own Qt (e.g. in Debug mode for use with the designer) set the
QT_QMAKE_EXECUTABLEshould be set to the path of the qmake.exe file, which is inside the bin directory (for example,
- You cannot use the same build tree for both release or debug mode builds. If both build types are needed, then the same source directory can be used, but a separate build directory should be created and configured for each build type.
- Windows doesn't support path longer than 260 characters, please make sure that the total path name of your
Slicer-builddirectory is no longer than 50 characters ( for example
c:\work\Slicer\Slicer-SuperBuild(32 characters) is fine)
- If you are making a release build, set your CMAKE_CONFIGURATION_TYPES to Release. Otherwise Visual Studio will select Debug by default and your build tree can end up with a mix of release and debug libraries.
- Step-by-step debug instuctions
- Configure using the following commands. By default CMAKE_BUILD_TYPE is set to Debug.
mkdir Slicer-SuperBuild-Debug cd Slicer-SuperBuild-Debug cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DQT_QMAKE_EXECUTABLE:FILEPATH=/path/to/QtSDK-1.2/Desktop/Qt/474/gcc/bin/qmake ../Slicer
where you replace /path/to with the real path on your machine where QtSDK-1.2 is located
- Using top-level directory name like
- Step-by-step debug instuctions
Two projects are generated by either
One of them is in the top-level bin directory
Slicer-SuperBuild and the other one is in the subdirectory
- The first project in
Slicer-SuperBuildmanages all the external dependencies of Slicer (VTK, ITK, Python, ...). To build Slicer for the first time, run make (or build the solution file in Visual Studio) in
Slicer-SuperBuild, which will update and build the external libraries and if successful will then build the subproject Slicer-build.
- The second project in
Slicer-SuperBuild/Slicer-buildis the "traditional" build directory of Slicer. After local changes in Slicer (or after an svn update on the source directory of Slicer), only running make (or building the solution file in Visual Studio) in
Slicer-SuperBuild/Slicer-buildis necessary (the external libraries are considered built and up to date).
- Warning: An significant amount of disk space is required to compile Slicer in Debug (>10GB on Windows)
Workaround firewall blocking git protocol
- Some firewall will be blocking the git protocol, a possible workaround is to configure Slicer disabling the option
Slicer_USE_GIT_PROTOCOL. Then http protocol will be used instead. Consider also reading https://github.com/commontk/CTK/issues/33
Notes for advanced users
- By default, if CMake finds Java on your machine, it automatically builds Java CLIs. If you don't want any Java in your Slicer (or if you don't want to install Java on your Mac Os X), you can pass
-DCMAKE_DISABLE_FIND_PACKAGE_Java:BOOL=TRUEwhen configuring Slicer.
- Same applies for OpenSSL:
CMAKE_DISABLE_FIND_PACKAGE_OpenSSL:BOOL=TRUEcan be passed when building Slicer for packaging.
After configuration, start the build process in the
|Linux or MacOSX (Makefile)||Windows (Visual Studio)|
Start a terminal.
$ cd ~/Projects/Slicer-SuperBuild $ make -j<NUMBEROFCORES>
Start Windows Explorer. Need help?
If you make local changes to Slicer, open the solution file located in the directory
|Linux or MacOSX||Windows|
Start a terminal.
Start Windows Explorer. Need help?
- Linux Ubuntu: if you have odd rendering artifacts, try disabling visual effects (System/Appearance/Visual Effects)
- Windows: If build was OK, but it Slicer doesn't start (gives the error: [bin/Release/SlicerQT-real.exe] exit abnormally - Report the problem.) then one possible root cause is that you have a copy of Python26.dll in your windows system directory (e.g., c:\Windows\System32\python26.dll). The solution is to rename or remove the python dll in the system directory. See more details here: http://www.na-mic.org/Bug/view.php?id=1180
CMake complains during configuration
CMake may not directly show what's wrong; try to look for log files of the form BUILD/CMakeFiles/*.log (where BUILD is your build directory) to glean further information.
A tool returned an error code from "Generating vtksysProcessFwd9xEnc.c"
The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail. Project : error PRJ0019: A tool returned an error code from "Generating vtksysProcessFwd9xEnc.c"
Install SP1 of Visual Studio
error: ‘class QList<QString>’ has no member named ‘reserve’
/nfs/Users/blowekamp/QtSDK/Desktop/Qt/474/gcc/include/QtCore/qdatastream.h: In function ‘QDataStream& operator>>(QDataStream&, QList<T>&) [with T = QString]’: /nfs/Users/blowekamp/QtSDK/Desktop/Qt/474/gcc/include/QtCore/qstringlist.h:247: instantiated from here /nfs/Users/blowekamp/QtSDK/Desktop/Qt/474/gcc/include/QtCore/qdatastream.h:246: error: ‘class QList<QString>’ has no member named ‘reserve’
You have multiple Qt versions installed on your machine. Try removing the Qt version installed on the system.
libarchive.so: undefined reference to `SHA256_Update'
Linking CXX executable ../../../../../bin/MRMLLogicCxxTests /home/benjaminlong/work/slicer/Slicer-SuperBuild-Debug/LibArchive-install/lib/libarchive.so: undefined reference to `SHA256_Update' /home/benjaminlong/work/slicer/Slicer-SuperBuild-Debug/LibArchive-install/lib/libarchive.so: undefined reference to `SHA256_Final' /home/benjaminlong/work/slicer/Slicer-SuperBuild-Debug/LibArchive-install/lib/libarchive.so: undefined reference to `SHA256_Init' /home/benjaminlong/work/slicer/Slicer-SuperBuild-Debug/LibArchive-install/lib/libarchive.so: undefined reference to `MD5_Init'
cd Slicer-SuperBuild rm -rf LibArchive-* make -j4
A tool returned an error code from "Performing configure step for ..."
CMake has some problems building complex projects on Windows7. See more details in: http://cmake.org/Bug/view.php?id=12957
A fix has been already identified and soon will be available in an official CMake release (probably 2.8.8). Until then this unofficial version can be used (based on CMake-2.8.7): https://qshare.queensu.ca/Users01/lasso/public/cmake-184.108.40.20657-win32-x86.exe.
A tool returned an error code from "Performing download step (git clone) for ..."
CMake has problems cloning git repositories on Windows7. See more details in http://cmake.org/Bug/view.php?id=12564
If you think the described problem is the same as you have, please add your specific error message to the bug report (the more people report the problem the sooner it will be fixed).
No rule to make target `/usr/lib/x86_64-linux-gnu/libGL.so'
X11 Window errors at start time
X Error: BadWindow (invalid Window parameter) 3 Extension: 137 (Uknown extension) Minor opcode: 4 (Unknown request) Resource id: 0x4200199 X Error: BadWindow (invalid Window parameter) 3 Extension: 137 (Uknown extension) Minor opcode: 4 (Unknown request) Resource id: 0x42001a6 X Error: BadWindow (invalid Window parameter) 3 Extension: 137 (Uknown extension) Minor opcode: 4 (Unknown request) Resource id: 0x42001b3
- Reinstall Nvidia drivers (that also rewrite the xorg.conf file).
error C2061: syntax error : identifier 'ssize_t'
4>1>Compiling... 4>1>version.c 4>1>c:\chene\winbin64\slicer4\cmcurl\urldata.h(585) : error C2061: syntax error : identifier 'ssize_t' 4>1>c:\chene\winbin64\slicer4\cmcurl\urldata.h(593) : error C2365: 'fread' : redefinition; previous definition was 'function' 4>1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(248) : see declaration of 'fread' 4>1>c:\chene\winbin64\slicer4\cmcurl\urldata.h(610) : error C2059: syntax error : '}'
ld: framework not found QtWebKit
[...] Linking CXX shared library libPythonQt.dylib ld: framework not found QtWebKit clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [libPythonQt.dylib] Error 1 [...]
See Slicer issue #2860
- Use a recent nightly build of CMake. It includes patch cc676c3a. Note also that the coming version of CMake 2.8.11 will work as expected.
On MacOSX 10.8, CMake hangs forever
Solution: Use CMake build >= 220.127.116.1130220-g53b279. See http://www.cmake.org/files/dev/cmake-18.104.22.16830220-g53b279-Darwin-universal.tar.gz
CMake folks (Thanks Brad King :)) fixed an issue that was preventing the most recent nightly from being used to successfully compile Slicer. The fix has been tested and is known to work. Tomorrow nightly build of CMake and by extension the coming release of CMake 2.8.11 will work.
If you are curious about the details, check the commit message:
The associated CMake test have also been updated:
Quick Build on Debian
sudo aptitude update sudo aptitude install subversion git gcc g++ make cmake-curses-gui libqt4-dev svn co http://svn.slicer.org/Slicer4/trunk Slicer mkdir Slicer-SuperBuild-Debug cd Slicer-SuperBuild-Debug cmake ../Slicer make -j5 # runtime dependency: sudo aptitude install python-tk