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

From Slicer Wiki
Jump to: navigation, search
(Prepend documentation/versioncheck template. See http://na-mic.org/Mantis/view.php?id=2887)
 
(201 intermediate revisions by 12 users not shown)
Line 1: Line 1:
The build system for [[Slicer4]] is being developed during the second half of 2010.  The goal is to provide a cross-platform build system that allows developers to quickly install and configure the multiple packages.
+
<noinclude>{{documentation/versioncheck}}</noinclude>
 +
<br>
 +
{{mbox
 +
| text = The goal of the [[{{tool|logo|cmake}}|x16px]] [{{tool|homepage|cmake}} CMake] '''Super-Build''' is to provide a cross-platform build system that allows developers to quickly install and configure the multiple packages.<br><br>Where [[Slicer3:Build_Instructions|Slicer3's build system]] relied on a [[Slicer3:getbuildtest|custom build script called getbuildtest]], new features added to [{{tool|homepage|cmake}} CMake], partly driven by slicer's requirements, allow porting of the scripts to rely more on native [{{tool|homepage|cmake}} CMake] functionality with the benefit that build script is more modular and general purpose.
 +
}}
 +
<br>
  
Where [[Slicer3:Build_Instructions|Slicer3's build system]] relied on a [[Slicer3:getbuildtest|custom build script called getbuildtest]], new features added to [http://www.cmake.org CMake], partly driven by slicer's requirements, allow porting of the scripts to rely more on native CMake functionality with the benefit that build script is more modular and general purpose.
+
== PREREQUISITES ==
 +
<br>
 +
<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>
  
== Prerequisites ==
+
<br><br><br><br>
* Install git version >= 1.6.5
 
** [http://git-scm.com/download Download Git]
 
** On linux, install git: <code>sudo apt-get install git</code>. If <code>git --version</code> is inferior to 1.6.5, then:<code>sudo dpkg --install git-core_1.6.5-1~bpo50+1_amd64.deb</code>
 
** On Windows, [http://code.google.com/p/msysgit/ msysgit] is advised. Using [http://code.google.com/p/tortoisegit/ TortoiseGit] is a plus.
 
* Linux prerequisites (''need to confirm'')
 
** 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) (and libosmesa6-dev on Ubuntu)
 
** glu (libglu1-mesa-dev on Ubuntu)
 
  
* Download (and if required compile) Qt - Use one of the link provided below:
+
== CHECKOUT slicer source files ==
{| border="1"
 
|- bgcolor="#FFFFCC"
 
!rowspan="3"|
 
!colspan="2" rowspan="2"|Linux
 
!colspan="2"|Mac
 
!colspan="2" rowspan="2"|Windows
 
|- bgcolor="#FFFFCC"
 
!colspan="1"|Tiger
 
!colspan="1"|Leopard, SnowLeopard
 
|- bgcolor="#FFFFCC"
 
!|32bits
 
!|64bits
 
!|32bits
 
!colspan="1"|64bits
 
!|32bits
 
!|64bits
 
|-
 
! bgcolor="#FFFFCC" | [http://get.qt.nokia.com/qt/source/ Qt source link]
 
|align="center" colspan="3"| [http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.0.tar.gz 4.7]
 
|align="center" colspan="1"| [http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.0.tar.gz 4.7]
 
|align="center" colspan="2"| [http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.0.zip 4.7]
 
|-
 
! bgcolor="#FFFFCC" | [http://get.qt.nokia.com/qt/source/  Qt binary link]
 
|align="center" colspan="1"| [http://get.qt.nokia.com/qtsdk/qt-sdk-linux-x86-opensource-2010.05.bin 4.7]
 
|align="center" colspan="1"| [http://get.qt.nokia.com/qtsdk/qt-sdk-linux-x86_64-opensource-2010.05.bin 4.7]
 
|align="center" colspan="1"| [http://get.qt.nokia.com/qt/source/qt-mac-carbon-opensource-4.7.0.dmg 4.7]
 
|align="center" colspan="1"| [http://get.qt.nokia.com/qtsdk/qt-sdk-mac-opensource-2010.05.dmg 4.7]
 
|align="center" colspan="1"| [http://get.qt.nokia.com/qt/source/qt-win-opensource-4.7.0-vs2008.exe 4.7 (vs2008)]
 
|align="center" colspan="1"| -
 
|}
 
  
* How to build Qt ?
+
Two options:  <code>svn</code>  or    <code>git-svn</code>
  
Configure options common to all platform:
+
To make '''review''' and '''integration''' of your welcome contributions, we recommends the use of <code>git-svn</code>
  
Check our different tutorials:
+
<br>
* Build Qt on Windows
+
{{ambox
Using the Qt Designer on Windows requires that the Slicer and CTK widget plugins are [http://doc.trolltech.com/4.6/deployment-plugins.html#debugging-plugins|compiled in the same mode than Qt]. If Qt was compiled in Release mode (default), Slicer would have to be compiled in Release mode as well. However if Qt is compiled in Debug mode only, Slicer has to be compiled in Debug too. When Qt is in "Release and Debug" mode only the Release version of Designer.exe is generated, Slicer would have to be compiled in Release. So for developers, the <b>Debug mode is recommended</b>, this is why we detail the compilation of Qt below.
+
| type  = warning
** 1/ Use a windows extracter to unzip the [#Prerequisites|Qt zip archive], don't use cygwin unzip it.
+
| text  = While it is not enforced, we strongly recommend you to '''AVOID''' the use of '''SPACES''' for both the <code>source directory</code> and the <code>build directory</code>. We mean it.
** 2/ launch the msvc2008 command prompt (MSVC08->Tools->Visual Studio 2008 CommandPrompt)
+
}}
** 3/ build with <code>configure.exe -platform win32-msvc2008 -debug</code>  
+
<br>
*** Note: the option <code>-prefix<code> doesn't work on Windows.
+
 
*** Note: According to [http://qt.nokia.com/doc/4.6/supported-platforms.html] Qt does not support msvc2008 on windows xp.  However, running <code>configure.exe</code> with no <code>-platform</code> argument seems to work. If you run configure with the <code>-platform</code> argument first by mistake, and if <code>configure -clean</code> doesn't work, then you may need to start from a fresh extraction from the .zip archive before running <code>configure.exe</code> again with no <code>-platform</code>, unless you can run <code>nmake</code> with the config clean target.
+
Note that even if you use <code>svn</code> to check out Slicer source code, you will need to have <code>git</code> installed to checkout and build other libraries. '''YES''', you need to install the things listed in the [[Documentation/{{documentation/version}}/Developers/Build Instructions/Prerequisites|prerequisites]] !.
** 4/ run <code>vcvars32.bat</code> first (required only if you use a regular command prompt, not the one in 2/).
+
 
** 5/ run <code>nmake</code>.
+
 
** Note: building with webkit support requires that <i>src/3rdparty/webkit/WebCore/tmp/moc/{debug,release}_shared/mocinclude.tmp</i> be removed. else you will get linker errors like <code>QNetworkReplyHandler.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall WebCore::FormDataIODevice::metaObject(void)const (?metaObject@FormDataIODevice@WebCore@@UBEPBUQMetaObject@@XZ)</code>
+
=== Using <code>git-svn</code> ===
** Node: If you encounter the following error <code>api\qscriptextensionplugin.h(43): Error: Undefined interface,</code>, delete the files <i>\src\script\tmp\moc\debug_shared\mocinclude.tmp</i> and <i>\src\script\tmp\moc\release_shared\mocinclude.tmp</i> and restart nmake. For more info, please see [http://bugreports.qt.nokia.com/browse/QTBUG-6470 QTBug 6470]].
+
 
* Build Qt on Linux
+
  git clone git://github.com/Slicer/Slicer.git
Downloading the binaries of Qt works fine with Linux, you do not have to compile Qt manually.
+
  cd Slicer
** Note: You need to install the libQtWebkit-devel package too
+
  git svn init http://svn.slicer.org/Slicer4/trunk
The following descriptions are given for people who want to  
+
  git update-ref refs/remotes/git-svn refs/remotes/origin/master
compile Qt anyway.
+
  git checkout master
 +
  git svn rebase
 +
 
 +
Consider reading the following page: [[Slicer:git-svn|Slicer guide to <code>git-svn</code>]]
 +
 
 +
=== Using <code>svn</code> ===
 +
 
 +
cd MyProjects
 +
svn co [http://svn.slicer.org/Slicer4/trunk http://svn.slicer.org/Slicer4/trunk] Slicer4
 +
 
 +
<br><br><br><br>
 +
 
 +
== CONFIGURE and generate Slicer solution files ==
 +
You can configure and generate Slicer solution files using either <code>ccmake</code> or <code>cmake-gui</code>.
 +
=== Per-platform instructions===
 +
==== Windows ====
 +
*'''Recommended''': <code>cmake-gui</code>
 +
** Configure using default options.
 +
* '''Remarks''':
 +
#If you downloaded the Qt binary then <code>qmake</code> will 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 <code>QT_QMAKE_EXECUTABLE</code> in <code>cmake-gui</code>.<code>QT_QMAKE_EXECUTABLE</code> should be set to the path of the qmake.exe file, which is inside the bin directory (for example, <code>/path/to/qt-everywhere-opensource-build-4.7.4/bin/qmake.exe</code>).  
 +
#Windows doesn't support path longer than 260 characters, please make sure that the total path name of your <code>Slicer-build</code> directory is no longer than 50 characters ( for example <code>c:\work\Slicer\Slicer-Superbuild</code> (32 characters) is fine)
 +
 
 +
==== Unix-like ====
 +
*'''Recommended''': <code>ccmake</code>
 +
** Configure using the following commands. By default '''CMAKE_BUILD_TYPE''' is set to '''Debug'''.
 
<pre>
 
<pre>
mkdir Qt
+
mkdir Slicer4-SuperBuild-Debug
mkdir Qt-build
+
cd Slicer4-SuperBuild-Debug
cd Qt
+
ccmake -DQT_QMAKE_EXECUTABLE:FILEPATH=/path/to/QtSDK-1.2/Desktop/Qt/474/gcc/bin/qmake ../Slicer4
wget http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.6.2.tar.gz
 
tar xvfz qt-everywhere-opensource-src-4.6.2.tar.gz
 
cd qt-everywhere-opensource-src-4.6.2
 
echo yes | ./configure -prefix ../../Qt-build -debug-and-release -opensource  -no-qt3support
 
make -j 16
 
make install
 
 
</pre>
 
</pre>
** Note: On a 64 bit system, you may have to add <code>-arch x86_64</code> to the Qt configure command line (?)
+
* '''Remarks''':
 +
# Using top-level directory name like <code>Slicer-Superbuild-Release</code> or <code>Slicer-Superbuild-Debug</code> is recommended.
 +
 
 +
=== General information ===
 +
 
 +
Two projects are generated by either <code>cmake</code>, <code>ccmake</code> or <code>cmake-gui</code>.
 +
 
 +
One of them is in the top-level bin directory <code>Slicer4-Superbuild</code> and the other one is in the subdirectory <code>Slicer-build</code>:
 +
 
 +
<pre>Slicer4-Superbuild/Slicer-build</pre>
 +
 
 +
# The first project in <code>Slicer4-Superbuild</code> 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 <code>Slicer4-Superbuild</code>, which will update and build the external libraries and if successful will then build the subproject Slicer-build.<br>
 +
# The second project in <code>Slicer4-Superbuild/Slicer-build</code> 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 <code>Slicer4-Superbuild/Slicer-build</code> is necessary (the external libraries are considered built and up to date). <br>
 +
#'''Warning''': An important 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 <code>Slicer_USE_GIT_PROTOCOL</code>. 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 <code>-DCMAKE_DISABLE_FIND_PACKAGE_Java:BOOL=TRUE</code> when configuring Slicer.
 +
* Same applies for OpenSSL: <code>CMAKE_DISABLE_FIND_PACKAGE_OpenSSL:BOOL=TRUE</code> can be passed when building Slicer for packaging.
 +
 
 +
<br><br><br><br>
 +
 
 +
== BUILD Slicer4 ==
 +
After configuration, start the build process in the  <code>Slicer4-SuperBuild</code> directory
 +
 
 +
=== Per-platform instructions===
 +
==== Windows ====
 +
* Open <code>Slicer4-SuperBuild\Slicer.sln</code> in Visual Studio
 +
* Select your build configuration. Usually '''Release''' of '''Debug'''
 +
* Build the <code>ALL_BUILD</code> project.
 +
 
 +
* If you make local changes to Slicer4, open the solution file located in the directory <code>Slicer4-SuperBuild/Slicer-build</code> instead. You should then be able to either build all projects or just a specific one.
 +
 
 +
==== Unix-like ====
 +
 
 +
  cd ~/Projects/Slicer4-SuperBuild
 +
  make -j<NUMBEROFCORES>
 +
 
 +
 
 +
<br><br><br><br>
 +
 
 +
== RUN Slicer ==
 +
=== Per-platform instructions===
 +
==== Windows ====
 +
 
 +
Run <code>Slicer4-SuperBuild/Slicer-build/Slicer.exe</code>
 +
 
 +
==== Unix-like ====
 +
 
 +
Run <code>Slicer4-SuperBuild/Slicer-build/Slicer</code>
 +
 
 +
<br><br><br><br>
 +
 
 +
== 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 ====
 +
NA
 +
 
 +
<br><br><br><br>
  
* Build Qt on Mac
+
== Common errors ==
Same as Linux. Use "-arch x86_64" for a 64 bit build on SnowLeopard.
+
=== 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.
  
== Step1 : Checkout slicer sources using subversion  ==
+
=== libarchive.so: undefined reference to `SHA256_Update' ===
For example:
+
 
<pre>
+
Linking CXX executable ../../../../../bin/MRMLLogicCxxTests
cd MyProjects
+
/home/benjaminlong/work/slicer/Slicer4-Superbuild-Debug/LibArchive-install/lib/libarchive.so: undefined reference to `SHA256_Update'
svn co http://svn.slicer.org/Slicer4/trunk Slicer4
+
/home/benjaminlong/work/slicer/Slicer4-Superbuild-Debug/LibArchive-install/lib/libarchive.so: undefined reference to `SHA256_Final'
</pre>
+
/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'
 +
 
 +
Solution:
 +
cd Slicer-superbuild
 +
rm -rf LibArchive-*
 +
make -j4
  
== Step2 : Configure slicer project using either ccmake or cmake-gui  ==
+
Details:
 +
* http://na-mic.org/Mantis/view.php?id=1616
 +
* http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=18923
 +
* http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=18969
  
The grids displayed below summarizes the available options.
+
=== A tool returned an error code from "Performing configure step for ..." ===
  
'''''Recommended:''' Using ccmake to compile QT only version with PythonQT support:''
+
Older CMake versions had some problems building complex projects on Windows7 (see more details in: http://cmake.org/Bug/view.php?id=12957).
<pre>
+
Make sure you use the required CMake version.
mkdir Slicer4-SuperBuild
 
cd Slicer4-SuperBuild
 
ccmake -DQT_QMAKE_EXECUTABLE:FILEPATH=/home/myself/qt-4.6.2/qt/bin/qmake -DSlicer3_USE_KWWIDGETS:BOOL=OFF -DSlicer3_USE_PYTHON:BOOL=OFF -DSlicer3_USE_QT:BOOL=ON -DSlicer3_USE_PYTHONQT:BOOL=ON -DSlicer3_USE_PYTHONQT_WITH_TCL:BOOL=ON ../Slicer4/SuperBuild
 
</pre>
 
For developers, set the '''CMAKE_BUILD_TYPE''' to '''Debug'''.
 
  
'''''More flexible option:''' Using ccmake (Additional configuration has to be set by using the flags shown in the table below)'':
+
=== A tool returned an error code from "Performing download step (git clone) for ..." ===
<pre>
 
mkdir Slicer4-SuperBuild
 
cd Slicer4-SuperBuild
 
ccmake -DQT_QMAKE_EXECUTABLE:FILEPATH=/home/myself/qt-4.6.2/qt/bin/qmake ../Slicer4/SuperBuild
 
</pre>
 
  
'''''More flexible option with GUI:''' Using cmake-gui (Additional configuration has to be set by using the flags shown in the grid below)''
+
CMake has problems cloning git repositories on Windows7. See more details in http://cmake.org/Bug/view.php?id=12564
<pre>
 
Where is the source code: C:/MyProjects/Slicer4/SuperBuild
 
Where to build the binaries: C:/MyProjects/Slicer4-SuperBuild
 
</pre>
 
  
Set of options and supported plateforms:
+
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).
  
{| border="1"
+
=== No rule to make target `/usr/lib/x86_64-linux-gnu/libGL.so' ===
|- bgcolor="#FFFFCC"
+
See http://techtidings.blogspot.com/2012/01/problem-with-libglso-on-64-bit-ubuntu.html
! rowspan="2"| Description
 
! colspan="4"| Options
 
! colspan="3"| Platform
 
|- bgcolor="#FFFFCC"
 
!| Slicer3_USE_KWWIDGETS
 
!| Slicer3_USE_PYTHON
 
!| Slicer3_USE_QT
 
!| Slicer3_USE_PYTHONQT
 
!| Linux
 
!| Mac
 
!| windows
 
|-
 
|align="center"|  Kww-Python '''DEFAULT'''
 
|align="center" bgcolor="lightgreen"| ON
 
|align="center" bgcolor="lightgreen"| ON
 
|align="center"| OFF
 
|align="center"| OFF
 
|align="center" bgcolor="lightgreen"| Y
 
|align="center" bgcolor="lightgreen"| Y
 
|align="center" bgcolor="lightgreen"| Y
 
|-
 
|align="center"| Kww-NoPython
 
|align="center" bgcolor="lightgreen"| ON
 
|align="center"| OFF
 
|align="center"| OFF
 
|align="center"| OFF
 
|align="center" bgcolor="lightgreen"| Y
 
|align="center" bgcolor="lightgreen"| Y
 
|align="center" bgcolor="lightgreen"| Y
 
|-
 
|align="center"| KwwAndQt-Python
 
|align="center" bgcolor="lightgreen"| ON
 
|align="center" bgcolor="lightgreen"| ON
 
|align="center" bgcolor="lightgreen"| ON
 
|align="center"| OFF
 
|align="center" bgcolor="lightgreen"| Y
 
|align="center" bgcolor="lightgray"| N
 
|align="center" bgcolor="lightgreen"| Y
 
|-
 
|align="center"| Qt-NoPythonQt
 
|align="center"| OFF
 
|align="center"| OFF
 
|align="center" bgcolor="lightgreen"| ON
 
|align="center"| OFF
 
|align="center" bgcolor="lightgreen"| Y
 
|align="center" bgcolor="lightgreen"| Y
 
|align="center" bgcolor="lightgreen"| Y
 
|-
 
|align="center"| Qt-PythonQt
 
|align="center"| OFF
 
|align="center"| OFF
 
|align="center" bgcolor="lightgreen"| ON
 
|align="center" bgcolor="lightgreen"| ON
 
|align="center" bgcolor="lightgreen"| Y
 
|align="center" bgcolor="lightgreen"| Y
 
|align="center" bgcolor="lightgreen"| Y
 
|}
 
  
'''After configuration, start the build process in the Slicer4-SuperBuild directory:'''
+
=== X11 Window errors at start time ===
 
<pre>
 
<pre>
make -j<NUMBEROFCORES>
+
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
 
</pre>
 
</pre>
  
On Mac OS X Snow Leopard and PythonQT enabled, there might be a complain about '''python-build/lib/libpython2.6.dylib not found'''. Please follow this workaround and then re-start the build process:
+
Solution:
 +
* Reinstall Nvidia drivers (that also rewrite the xorg.conf file).
 +
 
 +
=== error C2061: syntax error : identifier 'ssize_t' ===
 
<pre>
 
<pre>
cd python-build
+
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 : '}'
 +
</pre>
  
cmake -P ../python_configure_step.cmake
+
Solution:
cmake -P ../python_install_step.cmake
+
* See [[#A_tool_returned_an_error_code_from_.22Performing_configure_step_for_....22]]
</pre>
 
  
''What is the difference between Python and PythonQt build ?''
 
'''The Python option is an older slicer3 flag used to turn on the KWWidgets-based Python option and should not be used with Qt.  PythonQt refers to [http://pythonqt.sourceforge.net the PythonQt Project] which is being integrated with Slicer4.  Leave both options OFF for best results (PythonQt is still being debugged)'''
 
  
== Step3: Configure, Generate the solution files and Build ==
+
<br><br><br><br>
Two projects are generated by ccmake/cmake-gui: the top-level bin directory Slicer3-Superbuild and the subdirectory Slicer3-Superbuild/Slicer3-build.
 
The first project in Slicer3-Superbuild manages all the external dependencies of Slicer (VTK, ITK, Python, ...). Running make (or building the solution file on Visual Studio) will update and build the external libraries and if successful will then build the subproject Slicer3-build.<br>
 
The second project in Slicer3-Superbuild/Slicer3-build is the "traditional" build directory of Slicer. Running make will only build Slicer (the external libaries are considered built and up to date).<br>
 
To build Slicer the first time, run <code>make</code> in Slicer3-Superbuild. After local changes in Slicer (or after an svn update on the source directory of Slicer3), only running make in Slicer3-Superuild/Slicer3-build is necessary.<br>
 
Warning, a lot of space disk is necessary to compile Slicer (>10Go on Windows)
 
  
 
==Platform Notes==
 
==Platform Notes==
  
* On windows and mac python gets rebuilt every time you type make.
+
* Linux Ubuntu: if you have odd rendering artifacts, try disabling visual effects (System/Appearance/Visual Effects)
* You currently need to manually set the DYLD_LIBRARY_PATH (mac) and related paths to run the executable Slicer3-SuperBuild/Slicer3-build/bin/SlicerQT
+
* Unix-Like: remember that "make" wrapping calls to pull source makes it very much not idempotent; re-running make after a build error may get past the previously encountered error. Kind of like re-compiling LaTeX many times to fix references.  
export DYLD_LIBRARY_PATH=<path/to>/Slicer4-SuperBuild/CTK-build/CTK-build/bin:<path/to>/Slicer4-SuperBuild/CTK-build/CMakeExternals/Install/lib
+
* 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

Latest revision as of 07:36, 14 June 2013

Home < Documentation < 4.0 < Developers < Build Instructions


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




PREREQUISITES


To avoid
Common errors,
we
STRONGLY
recommend to read the
Prerequisites
section.





CHECKOUT slicer source files

Two options: svn or git-svn

To make review and integration of your welcome contributions, we recommends the use of git-svn



Note that even if you use svn to check out Slicer source code, you will need to have git installed to checkout and build other libraries. YES, you need to install the things listed in the prerequisites !.


Using git-svn

 git clone git://github.com/Slicer/Slicer.git
 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

Consider reading the following page: Slicer guide to git-svn

Using svn

cd MyProjects
svn co http://svn.slicer.org/Slicer4/trunk Slicer4





CONFIGURE and generate Slicer solution files

You can configure and generate Slicer solution files using either ccmake or cmake-gui.

Per-platform instructions

Windows

  • Recommended: cmake-gui
    • Configure using default options.
  • Remarks:
  1. If you downloaded the Qt binary then qmake will be detected and all paths will be set automatically.
  2. If you built your own Qt (e.g. in Debug mode for use with the designer) set the QT_QMAKE_EXECUTABLE in cmake-gui.QT_QMAKE_EXECUTABLE should be set to the path of the qmake.exe file, which is inside the bin directory (for example, /path/to/qt-everywhere-opensource-build-4.7.4/bin/qmake.exe).
  3. Windows doesn't support path longer than 260 characters, please make sure that the total path name of your Slicer-build directory is no longer than 50 characters ( for example c:\work\Slicer\Slicer-Superbuild (32 characters) is fine)

Unix-like

  • Recommended: ccmake
    • Configure using the following commands. By default CMAKE_BUILD_TYPE is set to Debug.
mkdir Slicer4-SuperBuild-Debug
cd Slicer4-SuperBuild-Debug
ccmake -DQT_QMAKE_EXECUTABLE:FILEPATH=/path/to/QtSDK-1.2/Desktop/Qt/474/gcc/bin/qmake ../Slicer4
  • Remarks:
  1. Using top-level directory name like Slicer-Superbuild-Release or Slicer-Superbuild-Debug is recommended.

General information

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

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

Slicer4-Superbuild/Slicer-build
  1. The first project in Slicer4-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 Slicer4-Superbuild, which will update and build the external libraries and if successful will then build the subproject Slicer-build.
  2. The second project in Slicer4-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 Slicer4-Superbuild/Slicer-build is necessary (the external libraries are considered built and up to date).
  3. Warning: An important 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=TRUE when configuring Slicer.
  • Same applies for OpenSSL: CMAKE_DISABLE_FIND_PACKAGE_OpenSSL:BOOL=TRUE can be passed when building Slicer for packaging.





BUILD Slicer4

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

Per-platform instructions

Windows

  • Open Slicer4-SuperBuild\Slicer.sln in Visual Studio
  • Select your build configuration. Usually Release of Debug
  • Build the ALL_BUILD project.
  • If you make local changes to Slicer4, open the solution file located in the directory Slicer4-SuperBuild/Slicer-build instead. You should then be able to either build all projects or just a specific one.

Unix-like

 cd ~/Projects/Slicer4-SuperBuild
 make -j<NUMBEROFCORES>






RUN Slicer

Per-platform instructions

Windows

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

Unix-like

Run Slicer4-SuperBuild/Slicer-build/Slicer





DEBUG Slicer

Per-platform instructions

Windows

  • Make sure you build Slicer using the Debug configuration.
  • Open a windows terminal cmd.exe
  • Execute the following command:
 cd \path\to\Slicer4-SuperBuild\Slicer-build
 Slicer.exe --VisualStudio Slicer.sln

Unix-like

NA





Common errors

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'

Solution:

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

Details:

A tool returned an error code from "Performing configure step for ..."

Older CMake versions had some problems building complex projects on Windows7 (see more details in: http://cmake.org/Bug/view.php?id=12957). Make sure you use the required CMake version.

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'

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:

* See #A_tool_returned_an_error_code_from_.22Performing_configure_step_for_....22






Platform Notes

  • Linux Ubuntu: if you have odd rendering artifacts, try disabling visual effects (System/Appearance/Visual Effects)
  • Unix-Like: remember that "make" wrapping calls to pull source makes it very much not idempotent; re-running make after a build error may get past the previously encountered error. Kind of like re-compiling LaTeX many times to fix references.
  • 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