- 1 PREREQUISITES
- 2 CHECKOUT slicer source files
- 3 CONFIGURE and generate Slicer solution files
- 4 BUILD Slicer
- 5 RUN Slicer
- 6 DEBUG Slicer
- 7 Common errors
- 7.1 A tool returned an error code from "Generating vtksysProcessFwd9xEnc.c"
- 7.2 error: ‘class QList<QString>’ has no member named ‘reserve’
- 7.3 libarchive.so: undefined reference to `SHA256_Update'
- 7.4 A tool returned an error code from "Performing configure step for ..."
- 7.5 A tool returned an error code from "Performing download step (git clone) for ..."
- 7.6 No rule to make target `/usr/lib/x86_64-linux-gnu/libGL.so'
- 7.7 X11 Window errors at start time
- 7.8 error C2061: syntax error : identifier 'ssize_t'
- 7.9 ld: framework not found QtWebKit
- 8 Platform Notes
- 9 Quick Build on Debian
recommend to read the
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.
On Windows enter the commands above in to a bash shell, such as Git Bash (part of msysgit) or use a Git client with a graphical user interface.
git svnbridge to ensure the mapping with svn revision.
git-svn is only required for core developers with svn access - other people can skip it.
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
Note for Mac OSX El Capitan:
You might need to link SVN from XCode if you find that
git svn is broken. To get correct links and bypass El Capitan's SIP use these commands
sudo mkdir /Library/Perl/5.18/auto sudo ln -s /Applications/Xcode.app/Contents/Developer/Library/Perl/5.18/darwin-thread-multi-2level/SVN /Library/Perl/5.18/darwin-thread-multi-2level sudo ln -s /Applications/Xcode.app/Contents/Developer/Library/Perl/5.18/darwin-thread-multi-2level/auto/SVN /Library/Perl/5.18/auto/
If you plan to compile Slicer to develop your own extensions and test these extensions on Slicer releases, it is convenient to download the source code directly from SVN and specify the revision number corresponding to the release you want. To do so, replace <MARKER> and <SVNREVISION> in the command below with the selected revision and marker:
svn co http://svn.slicer.org/Slicer4/<MARKER> Slicer-r<SVNREVISION> -r <SVNREVISION>
Release SVN revision# Marker 4.10.0 27501 trunk 4.8.1 26813 branches/Slicer-4-8 4.8.0 26489 trunk 4.6.2 25516 branches/Slicer-4-6 4.5.0-1 24735 trunk 4.4 23774 trunk 4.3.1 22599 branches/Slicer-4-3 4.3.0 22408 trunk
More corresponding SVN revision numbers can be found here and here. The <MARKER> can be found at the bottom of this page http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=SVNREVISION by replacing SVNREVISION with the selected revision.
For example, to checkout the source code associated with revision 4.8.1, you would use the following command:
svn co http://svn.slicer.org/Slicer4/branches/Slicer-4-8 Slicer-r26813 -r 26813
CONFIGURE and generate Slicer solution files
There are many ways of customizing Slicer's user interface or feature set. This section describes how a custom Slicer build can be configured at build-time. See an overview of various other options in this presentation.
You can configure and generate Slicer solution files using either
cmake-gui. To streamline this process, you can also use the SlicerCustomAppTemplate project maintained by Kitware.
Customizing application build
Customized editions of Slicer can be generated without changing Slicer source code, just by modifying CMake variables:
- SlicerApp_APPLICATION_NAME: Custom application name to be used, instead of default "Slicer". The name is used in installation package name, window title bar, etc.
- Slicer_DISCLAIMER_AT_STARTUP: String that is displayed to the user after first startup of Slicer after installation (disclaimer, welcome message, etc).
- Slicer_DEFAULT_HOME_MODULE: Module name that is activated automatically on application start.
- Slicer_DEFAULT_FAVORITE_MODULES: Modules that will be added to the toolbar by default for easy access. List contains module names, separated by space character.
- Slicer_CLIMODULES_DISABLED: Built-in CLI modules that will be removed from the application. List contains module names, separated by semicolon character.
- Slicer_QTLOADABLEMODULES_DISABLED: Built-in Qt loadable modules that will be removed from the application. List contains module names, separated by semicolon character.
- Slicer_QTSCRIPTEDMODULES_DISABLED: Built-in scripted loadable modules that will be removed from the application. List contains module names, separated by semicolon character.
- Slicer_USE_PYTHONQT_WITH_OPENSSL: enable/disable building the application with SSL support (ON/OFF)
- Slicer_USE_SimpleITK: enable/disable SimpleITK support (ON/OFF)
- Slicer_BUILD_SimpleFilters: enable/disable building SimpleFilters. Requires SimpleITK. (ON/OFF)
- Slicer_BUILD_EMSegment: enable/disable building EM segmenter (ON/OFF)
- Slicer_USE_PYTHONQT_WITH_TCL: TCL support (ON/OFF)
- Slicer_EXTENSION_SOURCE_DIRS: Defines additional extensions that will be included in the application package as built-in modules. Full paths of extension source directories has to be specified, separated by semicolons.
Recommended: run CMake (cmake-gui) from the Windows Start menu
- Set the build directory. Use a very short path, for example:
C:\D\S4for source code and for
C:\D\S4Dbuild directory are known to work.
- Because Windows doesn't support file path longer than 260 characters and has a maximum command line length, it is strongly recommended to choose a build directory that is no longer than 10 characters. If a longer path is used then build may or may not succeed.
- 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.
- Select your compiler: Visual Studio 14 2015 Win64
- Do not configure yet.
Qt5_DIRvariable pointing to Qt5 folder such as
C:\Qt\5.10.0\msvc2015_64\lib\cmake\Qt5: click Add entry button, set Name to Qt5_DIR, Type to PATH, and Value to the Qt5 folder.
- Click generate then close cmake-gui.
- If building in release mode:
- Open the top-level Slicer.sln file in the build directory in Visual Studio
- Set active configuration to Release. Visual Studio will select Debug build configuration by default when you first open the solution in the Visual Studio GUI. If you build Slicer in release mode and accidentally forget to switch the build configuration to Release then the build will fail. Note: you can avoid this manual configuration mode selection by setting
- If building in debug mode:
- Start Visual Studio using the Slicer launcher as described in Step-by-step debug instuctions
- Build the ALL_BUILD project
Alternative option: Configure and build using command-line or batch file
Instead of using CMake (cmake-gui), it is also possible to configure by creating a .bat file that contains command-line instructions and run this .bat file each time a Slicer needs to be re-built. The examples below assume Slicer source code is in
C:\D\S4 folder and Qt-5.10 is installed in default location.
Visual Studio 2015 in Release mode:
mkdir C:\D\S4R cd /d C:\D\S4R "C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 14 2015 Win64" -DQt5_DIR:PATH=C:\Qt\5.10.0\msvc2015_64\lib\cmake\Qt5 C:\D\S4 "C:\Program Files\CMake\bin\cmake.exe" --build . --config Release
Visual Studio 2015 in Debug mode:
mkdir C:\D\S4D cd /d C:\D\S4D "C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 14 2015 Win64" -DQt5_DIR:PATH=C:\Qt\5.10.0\msvc2015_64\lib\cmake\Qt5 C:\D\S4 "C:\Program Files\CMake\bin\cmake.exe" --build . --config Debug
Visual Studio 2017 with VS2015 toolset in Release mode:
mkdir C:\D\S4R cd /d C:\D\S4R "C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 15 2017 Win64" -T "v140" -DQt5_DIR:PATH=C:\Qt\5.10.0\msvc2015_64\lib\cmake\Qt5 C:\D\S4 "C:\Program Files\CMake\bin\cmake.exe" --build . --config Release
- 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 -DQt5_DIR:PATH=/path/to/Qt5.11.0/5.11.0/gcc_64/lib/cmake/Qt5 ../Slicer
where you replace /path/to/QtSDK with the real path on your machine where QtSDK is located
If using Qt from the system, do not forget to add the following CMake variable to your configuration command line:
- Instead of
cmake, you can use
cmake-guito visually inspect and edit configure options.
- Using top-level directory name like
- Step-by-step debug instuctions
- On Mac OS X 10.9 (Mavericks) / 10.10 (Yosemite) / 10.11 (El Capitan), also set the following variables (see discussion):
|CMAKE_OSX_DEPLOYMENT_TARGET||10.9 or 10.10 or 10.11|
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 for if the firewall is blocking git protocol
- Some firewalls will block the git protocol. A possible workaround is to configure Slicer by disabling the option
Slicer_USE_GIT_PROTOCOL. Then the http protocol will be used instead. Consider also reading https://github.com/commontk/CTK/issues/33
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
- Make sure you build Slicer using the Debug configuration.
- Open a windows terminal
- Execute the following command:
cd \path\to\Slicer4-SuperBuild\Slicer-build Slicer.exe --VisualStudio Slicer.sln
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/Slicer4-Superbuild-Debug/LibArchive-install/lib/libarchive.so: undefined reference to `SHA256_Update' /home/benjaminlong/work/slicer/Slicer4-Superbuild-Debug/LibArchive-install/lib/libarchive.so: undefined reference to `SHA256_Final' /home/benjaminlong/work/slicer/Slicer4-Superbuild-Debug/LibArchive-install/lib/libarchive.so: undefined reference to `SHA256_Init' /home/benjaminlong/work/slicer/Slicer4-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-126.96.36.19957-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
- A patch has been pushed to CMake next branch and will be integrated to CMake master when successfully tested. See http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cc676c3a
- Linux Ubuntu: if you have odd rendering artifacts, try disabling visual effects (System/Appearance/Visual Effects)
- Linux Ubuntu 12.04: if the QtSdk installation hangs, please try this solution
- 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
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 Slicer4 mkdir Slicer4-SuperBuild-Debug cd Slicer4-SuperBuild-Debug cmake ../Slicer4 make -j5 # runtime dependency: sudo aptitude install python-tk