Difference between revisions of "Documentation/Nightly/Developers/Build Instructions"

From Slicer Wiki
Jump to: navigation, search
(48 intermediate revisions by 10 users not shown)
Line 1: Line 1:
== PREREQUISITES ==
+
<noinclude>{{documentation/versioncheck}}</noinclude>
<br>
+
{{:{{FULLPAGENAME}}/Prerequisites}}
<center>To avoid <br>[[#Common_errors|'''Common errors''']], <br>we<br> '''STRONGLY'''<br> recommend to read the<br> <font size="+2">[[Documentation/{{documentation/version}}/Developers/Build Instructions/Prerequisites|Prerequisites]]</font><br> section.</center>
 
  
 
<br><br><br><br>
 
<br><br><br><br>
Line 17: Line 16:
 
<br><br><br><br>
 
<br><br><br><br>
  
== RUN Slicer ==
+
{{:{{FULLPAGENAME}}/Run}}
=== Per-platform instructions===
 
==== Windows ====
 
  
Run <code>Slicer4-SuperBuild/Slicer-build/Slicer.exe</code>
+
<br><br><br><br>
  
==== Unix-like ====
+
{{:{{FULLPAGENAME}}/Test}}
  
Run <code>Slicer4-SuperBuild/Slicer-build/Slicer</code>
+
<br><br><br><br>
  
<br><br><br><br>
+
{{:{{FULLPAGENAME}}/Package}}
  
 +
<!--
 
== DEBUG Slicer ==
 
== DEBUG Slicer ==
=== Per-platform instructions===
 
==== Windows ====
 
* Make sure you build Slicer using the '''Debug''' configuration.
 
* Open a windows terminal <code>cmd.exe</code>
 
* Execute the following command:
 
  cd \path\to\Slicer4-SuperBuild\Slicer-build
 
  Slicer.exe --VisualStudio Slicer.sln
 
  
==== Unix-like ====
+
To be able to debug Slicer application, you are expected to build it with Debug symbols in a clean directory.
NA
+
 
 +
{|width = "100%"
 +
! width="50%" style="border-bottom: 1px solid darkgrey;font-size: 75%;"| Linux or MacOSX
 +
! width="50%" style="border-bottom: 1px solid darkgrey;font-size: 75%;"| Windows (Visual Studio)
 +
|-
 +
| valign="top" |
 +
Configure Slicer using <code>-DCMAKE_BUILD_TYPE:STRING=Debug</code>
 +
| valign="top" |
 +
Selecting <code>Debug</code> configuration in Visual Studio.
 +
|}
 +
 
 +
{|width = "100%"
 +
! width="50%" style="border-bottom: 1px solid darkgrey;font-size: 75%;"| Linux or MacOSX
 +
! width="50%" style="border-bottom: 1px solid darkgrey;font-size: 75%;"| Windows (Visual Studio)
 +
|-
 +
| valign="top" |
 +
<br>
 +
{{wip}} TBD
 +
<br>
 +
| valign="top" |
 +
<ol start="1" style="list-style-type: decimal;">
 +
<li>Press "Win-R," type "cmd" and press "Enter" to open a Command Prompt session.</li>
 +
<li>
 +
  <p>Start Visual Studio with Slicer environment:</p>
 +
  <pre>&gt; cd \path\to\Slicer-SuperBuild\Slicer-build
 +
&gt; Slicer.exe --VisualStudio Slicer.sln</pre>
 +
</li>
 +
</ol>
 +
|}
  
 
<br><br><br><br>
 
<br><br><br><br>
 +
-->
  
 
== Common errors ==
 
== Common errors ==
 +
 +
=== 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" ===
 
=== A tool returned an error code from "Generating vtksysProcessFwd9xEnc.c" ===
 
  The application has failed to start because its side-by-side configuration is incorrect.
 
  The application has failed to start because its side-by-side configuration is incorrect.
Line 49: Line 73:
 
  Project : error PRJ0019: A tool returned an error code from "Generating
 
  Project : error PRJ0019: A tool returned an error code from "Generating
 
  vtksysProcessFwd9xEnc.c"
 
  vtksysProcessFwd9xEnc.c"
Install [[Documentation/{{documentation/version}}/Developers/Build_Instructions/Prerequisites#Windows|SP1 of Visual Studio]]
+
'''Suggested solution: [[Documentation/{{documentation/version}}/Developers/Build_Instructions/Prerequisites#Windows|Install SP1 of Visual Studio]]'''
 +
 
 +
See also:
 +
 
 +
* [http://www.kitware.com/blog/home/post/4|"Deploying on Windows with DLL Manifest Issues"] (Bill Hoffman, Kitware blog).
 +
* [https://stackoverflow.com/questions/13217174/how-to-properly-setup-vs2008-for-x64-programing/13222870#13222870| How to create a custom installer to correct a missing WinSXS manifest entry] (StackOverflow).
  
 
=== error: ‘class QList<QString>’ has no member named ‘reserve’ ===
 
=== error: ‘class QList<QString>’ has no member named ‘reserve’ ===
Line 60: Line 89:
  
 
  Linking CXX executable ../../../../../bin/MRMLLogicCxxTests
 
  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/Slicer-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/Slicer-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/Slicer-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'
+
  /home/benjaminlong/work/slicer/Slicer-SuperBuild-Debug/LibArchive-install/lib/libarchive.so: undefined reference to `MD5_Init'
  
 
Solution:
 
Solution:
  cd Slicer-superbuild
+
  cd Slicer-SuperBuild
 
  rm -rf LibArchive-*
 
  rm -rf LibArchive-*
 
  make -j4
 
  make -j4
Line 74: Line 103:
 
* http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=18923
 
* http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=18923
 
* http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=18969
 
* http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=18969
 
=== 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-2.8.7.12957-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' ===
 
=== No rule to make target `/usr/lib/x86_64-linux-gnu/libGL.so' ===
Line 141: Line 158:
 
* Use a [http://www.cmake.org/files/dev/?C=M;O=D recent nightly build of CMake]. It includes patch [http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cc676c3a cc676c3a]. Note also that the coming version of CMake 2.8.11 will work as expected.
 
* Use a [http://www.cmake.org/files/dev/?C=M;O=D recent nightly build of CMake]. It includes patch [http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cc676c3a cc676c3a]. Note also that the coming version of CMake 2.8.11 will work as expected.
  
<br><br><br><br>
+
=== On MacOSX 10.8, CMake hangs forever ===
 +
 
 +
Issue: http://www.na-mic.org/Bug/view.php?id=2957
 +
 
 +
Solution: Use CMake build >= 2.8.10.20130220-g53b279. See http://www.cmake.org/files/dev/cmake-2.8.10.20130220-g53b279-Darwin-universal.tar.gz
 +
 
 +
Details:
 +
 
 +
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:
 +
 
 +
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1df09e57 [^]
 +
 
 +
The associated CMake test have also been updated:
 +
 
 +
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bff3d9ce [^]
 +
 
 +
<br><br>
 +
 
 +
=== On MacOSX 10.8/10.9 with XQuartz, 'X11/Xlib.h' file not found ===
 +
 
 +
Issue: http://www.na-mic.org/Bug/view.php?id=3405
 +
 
 +
Workaround: Build with -DSlicer_USE_PYTHONQT_WITH_TCL:BOOL=OFF
 +
 
 +
Tcl is required only for EMSegment module.
 +
 
 +
Details: See http://www.na-mic.org/Bug/view.php?id=3405
 +
<br><br>
 +
 
 +
=== svn: E175002: Unable to connect to a repository at URL XXX ===
 +
 
 +
Issue: Cisco AnyConnect is installed with the "Web Security" option checked (default), which blocks Subversion checkouts even when inactive!
 +
 
 +
Solution:  Uninstall and reinstall Cisco AnyConnect, deselecting the "Web Security" feature during install
 +
 
 +
[[File:CiscoAnyConnectInstallOptions.png]]
 +
 
 +
=== My antivirus software reports that files in my build directory are infected ===
 +
 
 +
Although usually antivirus software does not interfere with the build process, it is recommended to disable antivirus and search indexing for build directories to improve performance and minimize the chance of concurrent file access problems.
 +
 
 +
=== Visual Studio compiler crashes ===
 +
 
 +
* If you use Visual Studio 2008, make sure Visual Studio 2008 service pack 1 is installed
 +
* Build Slicer in a short directory, for example source code in <tt>C:\D\S4</tt>, binary directory <tt>C:\D\S4D</tt> or <tt>C:\D\S4R</tt>
 +
 
 +
=== 'QSslSocket' : is not a class or namespace name ===
 +
 
 +
This error message occurs if Slicer is configured to use SSL but Qt is built without SSL support.
 +
 
 +
Either set Slicer_USE_PYTHONQT_WITH_OPENSSL to OFF when configuring Slicer build in CMake, or build Qt with SSL support.
 +
 
 +
=== error: Missing Qt module QTWEBKIT ===
 +
 
 +
CMake Error at CMake/SlicerBlockFindQtAndCheckVersion.cmake:43 (message):
 +
  error: Missing Qt module QTWEBKIT
 +
Call Stack (most recent call first):
 +
  CMake/SlicerBlockFindQtAndCheckVersion.cmake:88 (__SlicerBlockFindQtAndCheckVersion_find_qt)
 +
  CMakeLists.txt:607 (include)
 +
 
 +
Solution:
 +
sudo apt-get -y install libqtwebkit-dev
 +
 
 +
Details:
 +
* http://slicer-devel.65872.n3.nabble.com/Re-slicer-devel-Digest-Vol-143-Issue-39-td4037122.html
 +
 
 +
=== error when starting Slicer: NameError: name 'getSlicerRCFileName' is not defined ===
 +
 
 +
./Slicer
 +
Traceback (most recent call last):
 +
  File "<string>", line 7, in <module>
 +
  File "/home/fbudin/Devel/Slicer-SuperBuild-Release/Slicer-build/bin/Python/slicer/slicerqt.py", line 6, in <module>
 +
    import vtk
 +
  File "/home/fbudin/Devel/Slicer-SuperBuild-Release/VTKv7-build/Wrapping/Python/vtk/__init__.py", line 41, in <module>
 +
    from .vtkCommonKit import *
 +
  File "/home/fbudin/Devel/Slicer-SuperBuild-Release/VTKv7-build/Wrapping/Python/vtk/vtkCommonKit.py", line 9, in <module>
 +
    from vtkCommonKitPython import *
 +
ImportError: /home/fbudin/Devel/Slicer-SuperBuild-Release/VTKv7-build/lib/./libvtkCommonKitPython27D-7.1.so.1: undefined symbol: PyUnicodeUCS2_DecodeUTF8
 +
Traceback (most recent call last):
 +
  File "<string>", line 1, in <module>
 +
NameError: name 'getSlicerRCFileName' is not defined
 +
Number of registered modules: 138
 +
error: [/home/fbudin/Devel/Slicer-SuperBuild-Release/Slicer-build/bin/./SlicerApp-real] exit abnormally - Report the problem.
 +
 
 +
Solution and details [http://na-mic.org/Mantis/view.php?id=3574 here]
 +
 
 +
=== macOS: error while configuring PCRE: "cannot run C compiled program" ===
 +
If the XCode command line tools are not properly set up on OS X, PCRE could fail to build in the Superbuild process with the errors like below:
 +
configure: error: in `/Users/fedorov/local/Slicer4-Debug/PCRE-build':
 +
configure: error: cannot run C compiled programs.
 +
 
 +
To install XCode command line tools, use the following command from the terminal:
 +
  xcode-select --install
  
==Platform Notes==
+
=== macOS: dyld: malformed mach-o: load commands size (...) > 32768 ===
  
* Linux Ubuntu: if you have odd rendering artifacts, try disabling visual effects (System/Appearance/Visual Effects)
+
Path of source or build folder is too long. For example building Slicer in ''/User/somebody/projects/something/dev/slicer/slicer-qt5-rel'' may fail with malformed mach-o error, while it succeeds in ''/sq5'' folder. To resolve this error, move source and binary files into a folder with shorter full path and restart the build from scratch (the build tree is not relocatable).
* Linux Ubuntu 12.04: if the QtSdk installation hangs, please try [[Documentation/4.1/Developers/Build_Instructions/Prerequisites/Qt/Instal_QtSDK1.2_Offline_Linux_64#Potential_Errors|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==
+
== Quick Build on Debian ==
 
  sudo aptitude update
 
  sudo aptitude update
 
  sudo aptitude install subversion git gcc g++ make cmake-curses-gui libqt4-dev
 
  sudo aptitude install subversion git gcc g++ make cmake-curses-gui libqt4-dev
  svn co http://svn.slicer.org/Slicer4/trunk Slicer4
+
  svn co http://svn.slicer.org/Slicer4/trunk Slicer
  mkdir Slicer4-SuperBuild-Debug
+
  mkdir Slicer-SuperBuild-Debug
  cd Slicer4-SuperBuild-Debug
+
  cd Slicer-SuperBuild-Debug
  cmake ../Slicer4
+
  cmake ../Slicer
 
  make -j5
 
  make -j5
 
   
 
   
 
  # runtime dependency:
 
  # runtime dependency:
 
  sudo aptitude install python-tk
 
  sudo aptitude install python-tk
 +
 +
 +
== Quick Build on Fedora 20 ==
 +
 +
Thanks to Bill Lorensen, you will find below the instruction to quickly build Slicer on Fedora 20:
 +
 +
yum groupinstall "C Development Tools"
 +
yum install git-core
 +
yum install svn
 +
yum install libX11-devel
 +
yum install libXt-devel
 +
yum install mesa-libGL-devel
 +
yum install mesa-libGLU-devel
 +
yum install cmake
 +
yum install tcl-devel
 +
yum install python-devel
 +
yum install qt-devel
 +
yum install qt-webkit-devel
 +
 +
svn co http://svn.slicer.org/Slicer4/trunk Slicer
 +
mkdir Slicer-SuperBuild-Debug
 +
cd Slicer-SuperBuild-Debug
 +
cmake ../Slicer
 +
make -j5
 +
 +
Reference: http://slicer-devel.65872.n3.nabble.com/Fedora-20-Slicer-Experience-tt4030845.html

Revision as of 23:02, 15 April 2019

Home < Documentation < Nightly < Developers < Build Instructions


For the latest Slicer documentation, visit the read-the-docs.


This page has been moved to read-the-docs.






CHECKOUT slicer source files


Check out the code using git:

  1. While it is not enforced, we strongly recommend you to AVOID the use of SPACES for both the source directory and the build directory. We mean it.
  1. Due to maximum path length limitations during build the build process, source and build folders must be located in a folder with very short total path length. This is expecially critical on Windows and MacOS. For example, C:\D\S4 for source and C:\D\S4R for release-mode build folder works on Windows; and /sq5 has been confirmed to work on MacOS.
  1. Clone the github repository

    cd MyProjects
    git clone git://github.com/Slicer/Slicer.git

    The Slicer directory is automatically created after cloning Slicer.

  2. 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.







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 ccmake or 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.

Per-platform instructions

Windows

Recommended: run CMake (cmake-gui) from the Windows Start menu

  • Set the build directory. Use a very short path, for example: C:\D\S4 for source code and for C:\D\S4D build 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 16 2019 Win64
  • Do not configure yet.
  • Add Qt5_DIR variable pointing to Qt5 folder such as C:\Qt\5.15.0\msvc2019_64\lib\cmake\Qt5: click Add entry button, set Name to Qt5_DIR, Type to PATH, and Value to the Qt5 folder.
  • Configure
  • 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 CMAKE_CONFIGURATION_TYPES to Release in cmake-gui.
  • If building in debug mode:
  • 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 16 2019 Win64" -DQt5_DIR:PATH=C:\Qt\5.15.0\msvc2019_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 16 2019 Win64" -DQt5_DIR:PATH=C:\Qt\5.15.0\msvc2019_64\lib\cmake\Qt5 C:\D\S4
"C:\Program Files\CMake\bin\cmake.exe" --build . --config Debug

Visual Studio 2019 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 16 2019 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

Unix-like

  • Recommended:
    • 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.15.0/5.15.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:

-DSlicer_USE_SYSTEM_QT:BOOL=1
  • Remarks:
  1. Instead of cmake, you can use ccmake or cmake-gui to visually inspect and edit configure options.
  2. Using top-level directory name like Slicer-SuperBuild-Release or Slicer-SuperBuild-Debug is recommended.
  3. 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):
Variable Description
Slicer_USE_PYTHONQT_WITH_TCL OFF
CMAKE_OSX_DEPLOYMENT_TARGET 10.9 or 10.10 or 10.11

General information

Two projects are generated by either cmake, ccmake or cmake-gui.

One of them is in the top-level bin directory Slicer-SuperBuild and the other one is in the subdirectory Slicer-build:

Slicer-SuperBuild/Slicer-build
  1. The first project in Slicer-SuperBuild manages 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.
  2. The second project in Slicer-SuperBuild/Slicer-build is 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-build is necessary (the external libraries are considered built and up to date).
  3. 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






BUILD Slicer

After configuration, start the build process in the Slicer-SuperBuild directory

Linux or MacOSX (Makefile) Windows (Visual Studio)

Start a terminal.

$ cd ~/Projects/Slicer-SuperBuild

$ make -j<NUMBEROFCORES>

In case of file download hash mismatch error, you need to acquire the latest wget, and build cmake with OpenSSL turned on. For more information, see here and here

When using the -j option, the build will continue past the source of the first error. If the build fails and you don't see what failed, rebuild without the -j option. Or, to speed up this process build first with the -j and -k options and then run plain make. The -k option will make the build keep going so that any code that can be compiled independent of the error will be completed and the second make will reach the error condition more efficiently.

Start Windows Explorer. Need help?

  1. Open Slicer-SuperBuild\Slicer.sln in Visual Studio
  2. Select build configuration. Usually Release or Debug
  3. Select menu Project -> Build Solution

If you make local changes to Slicer, open the solution file located in the directory Slicer-SuperBuild/Slicer-build instead. You should then be able to either build all projects or just a specific one.






RUN Slicer

Linux or MacOSX Windows

Start a terminal.

$ Slicer-SuperBuild/Slicer-build/Slicer

Start Windows Explorer. Need help?

Run Slicer-SuperBuild/Slicer-build/Slicer.exe

Notes:

  • Linux Ubuntu: if you have odd rendering artifacts, try disabling visual effects (System/Appearance/Visual Effects)
  • Windows: If build was OK, but Slicer doesn't start (e.g. 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






TEST Slicer

After building, run the tests in the Slicer-SuperBuild/Slicer-build directory

Linux or MacOSX (Makefile) Windows (Visual Studio)

Start a terminal.

$ cd ~/Projects/Slicer-SuperBuild/Slicer-build

$ ctest -j<NUMBEROFCORES>

Start Windows Explorer. Need help?

  1. Open Slicer-SuperBuild\Slicer.sln in Visual Studio
  2. Select build configuration. Usually Release or Debug
  3. In the Solution Explorer, right click on RUN_TESTS project and then select Build

Note: RUN_TESTS project can be found in the CMakePredefinedTargets folder. See here for more details.

Slicer-vs2013-CMakePredefinedTargets-RUN TESTS.png






PACKAGE Slicer

Linux or MacOSX (Makefile) Windows (Visual Studio)

Start a terminal.

$ cd ~/Projects/Slicer-SuperBuild
$ cd Slicer-build

$ make package

Note: Make sure to patch VS2008 using the script fix-vc9-redist-manifests.ps1
Start Windows Explorer. Need help?

  1. Open Slicer-SuperBuild\Slicer-build\Slicer.sln in Visual Studio
  2. Select Release build configuration.
  3. In the Solution Explorer, right click on PACKAGE project in group CMakePredefinedTargets and then select Build

Note: PACKAGE project can be found in the CMakePredefinedTargets folder. See here for more details.

Slicer-vs2013-CMakePredefinedTargets-PACKAGE.png


Common errors

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"

Suggested solution: Install SP1 of Visual Studio

See also:

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'

Solution:

cd Slicer-SuperBuild
rm -rf LibArchive-*
make -j4

Details:

No rule to make target `/usr/lib/x86_64-linux-gnu/libGL.so'

See http://techtidings.blogspot.com/2012/01/problem-with-libglso-on-64-bit-ubuntu.html

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

Solution:

  • 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 : '}'

Solution:

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[8]: *** [libPythonQt.dylib] Error 1
[...]

See Slicer issue #2860

Workaround:

Solution:

On MacOSX 10.8, CMake hangs forever

Issue: http://www.na-mic.org/Bug/view.php?id=2957

Solution: Use CMake build >= 2.8.10.20130220-g53b279. See http://www.cmake.org/files/dev/cmake-2.8.10.20130220-g53b279-Darwin-universal.tar.gz

Details:

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:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1df09e57 [^]

The associated CMake test have also been updated:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bff3d9ce [^]



On MacOSX 10.8/10.9 with XQuartz, 'X11/Xlib.h' file not found

Issue: http://www.na-mic.org/Bug/view.php?id=3405

Workaround: Build with -DSlicer_USE_PYTHONQT_WITH_TCL:BOOL=OFF

Tcl is required only for EMSegment module.

Details: See http://www.na-mic.org/Bug/view.php?id=3405

svn: E175002: Unable to connect to a repository at URL XXX

Issue: Cisco AnyConnect is installed with the "Web Security" option checked (default), which blocks Subversion checkouts even when inactive!

Solution: Uninstall and reinstall Cisco AnyConnect, deselecting the "Web Security" feature during install

CiscoAnyConnectInstallOptions.png

My antivirus software reports that files in my build directory are infected

Although usually antivirus software does not interfere with the build process, it is recommended to disable antivirus and search indexing for build directories to improve performance and minimize the chance of concurrent file access problems.

Visual Studio compiler crashes

  • If you use Visual Studio 2008, make sure Visual Studio 2008 service pack 1 is installed
  • Build Slicer in a short directory, for example source code in C:\D\S4, binary directory C:\D\S4D or C:\D\S4R

'QSslSocket' : is not a class or namespace name

This error message occurs if Slicer is configured to use SSL but Qt is built without SSL support.

Either set Slicer_USE_PYTHONQT_WITH_OPENSSL to OFF when configuring Slicer build in CMake, or build Qt with SSL support.

error: Missing Qt module QTWEBKIT

CMake Error at CMake/SlicerBlockFindQtAndCheckVersion.cmake:43 (message):
 error: Missing Qt module QTWEBKIT
Call Stack (most recent call first):
 CMake/SlicerBlockFindQtAndCheckVersion.cmake:88 (__SlicerBlockFindQtAndCheckVersion_find_qt)
 CMakeLists.txt:607 (include)

Solution:

sudo apt-get -y install libqtwebkit-dev

Details:

error when starting Slicer: NameError: name 'getSlicerRCFileName' is not defined

./Slicer Traceback (most recent call last):

 File "<string>", line 7, in <module>
 File "/home/fbudin/Devel/Slicer-SuperBuild-Release/Slicer-build/bin/Python/slicer/slicerqt.py", line 6, in <module>
   import vtk
 File "/home/fbudin/Devel/Slicer-SuperBuild-Release/VTKv7-build/Wrapping/Python/vtk/__init__.py", line 41, in <module>
   from .vtkCommonKit import *
 File "/home/fbudin/Devel/Slicer-SuperBuild-Release/VTKv7-build/Wrapping/Python/vtk/vtkCommonKit.py", line 9, in <module>
   from vtkCommonKitPython import *

ImportError: /home/fbudin/Devel/Slicer-SuperBuild-Release/VTKv7-build/lib/./libvtkCommonKitPython27D-7.1.so.1: undefined symbol: PyUnicodeUCS2_DecodeUTF8 Traceback (most recent call last):

 File "<string>", line 1, in <module>

NameError: name 'getSlicerRCFileName' is not defined Number of registered modules: 138 error: [/home/fbudin/Devel/Slicer-SuperBuild-Release/Slicer-build/bin/./SlicerApp-real] exit abnormally - Report the problem.

Solution and details here

macOS: error while configuring PCRE: "cannot run C compiled program"

If the XCode command line tools are not properly set up on OS X, PCRE could fail to build in the Superbuild process with the errors like below:

configure: error: in `/Users/fedorov/local/Slicer4-Debug/PCRE-build':
configure: error: cannot run C compiled programs.

To install XCode command line tools, use the following command from the terminal:

 xcode-select --install

macOS: dyld: malformed mach-o: load commands size (...) > 32768

Path of source or build folder is too long. For example building Slicer in /User/somebody/projects/something/dev/slicer/slicer-qt5-rel may fail with malformed mach-o error, while it succeeds in /sq5 folder. To resolve this error, move source and binary files into a folder with shorter full path and restart the build from scratch (the build tree is not relocatable).

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


Quick Build on Fedora 20

Thanks to Bill Lorensen, you will find below the instruction to quickly build Slicer on Fedora 20:

yum groupinstall "C Development Tools"
yum install git-core
yum install svn
yum install libX11-devel
yum install libXt-devel
yum install mesa-libGL-devel
yum install mesa-libGLU-devel
yum install cmake
yum install tcl-devel
yum install python-devel
yum install qt-devel
yum install qt-webkit-devel
svn co http://svn.slicer.org/Slicer4/trunk Slicer
mkdir Slicer-SuperBuild-Debug
cd Slicer-SuperBuild-Debug
cmake ../Slicer
make -j5

Reference: http://slicer-devel.65872.n3.nabble.com/Fedora-20-Slicer-Experience-tt4030845.html