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

From Slicer Wiki
Jump to: navigation, search
Line 54: Line 54:
* How to build Qt ?
Configure options common to all platform:
Check our different tutorials:
'''''Recommended:''' download the pre-compiled Qt unless you know you need to build from source to use the Qt Designer''
* Build Qt on Windows
** Using the Qt Designer on Windows requires that the Slicer plugins are [http://doc.trolltech.com/4.6/deployment-plugins.html#debugging-plugins|compiled in the same mode as 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.
*# Use a windows extracter to unzip the [#Prerequisites|Qt zip archive], don't use cygwin unzip it.
*# launch the msvc2008 command prompt (MSVC08->Tools->Visual Studio 2008 CommandPrompt) (or: launch cmd.exe and run <code>vcvars32.bat</code>)
*# build with <code>configure.exe -platform win32-msvc2008 -debug</code>
*#* When asked, choose open source license type (o), then accept the license (y)
*#* Note: the option <code>-prefix</code> doesn't work on Windows.
*#* Note: According to [http://qt.nokia.com/doc/4.7/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: for Microsoft Visual Studio 2010 users, Qt 4.6.3 is hard to configure with MSVC2010, use Qt 4.7.x instead.
*# 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>
*#* Note: 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
**Downloading the binaries of Qt works fine with Linux, you do not have to compile Qt manually.
** Note: You need to install the libQtWebkit-devel package too
The following descriptions are given for people who want to
compile Qt anyway.
mkdir Qt
mkdir Qt-build
cd Qt
wget http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.6.3.tar.gz
tar xvfz qt-everywhere-opensource-src-4.6.3.tar.gz
cd qt-everywhere-opensource-src-4.6.3
echo yes | ./configure -prefix ../../Qt-build -debug-and-release -opensource  -no-qt3support
make -j 16
make install
** Note: On a 64 bit system, you may have to add <code>-arch x86_64</code> to the Qt configure command line (?)
* Build Qt on Mac
Same as Linux. Use the flag <code>-cocoa</code> on the configure command-line(the <code>-shared</code> flag should be set automatically); for a 64 bit build on SnowLeopard use <code>-arch x86_64</code>. For more information go to http://doc.qt.nokia.com/4.6/developing-on-mac.html (warning  default values are different: <code>-carbon</code> vs <code>-cocoa</code> for Qt 4.7: http://doc.qt.nokia.com/4.7/developing-on-mac.html)
== Step1: Checkout slicer sources using subversion  ==
== Step1: Checkout slicer sources using subversion  ==

Revision as of 14:17, 15 June 2011

Home < Documentation < 4.0 < Developers < Build Instructions

Back to Slicer 4

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.

Where Slicer3's build system relied on a custom build script called getbuildtest, new features added to 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.


  • CMake version >= 2.8.2
  • 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)
    • git version >= 1.6.5
      • Download Git
      • install git: sudo apt-get install git. If git --version is inferior to 1.6.5, then:sudo dpkg --install git-core_1.6.5-1~bpo50+1_amd64.deb
  • Windows prerequisites
  • Download (and if required compile) Qt - Use one of the link provided below:
Linux Mac Windows
Tiger Leopard, SnowLeopard
32bits 64bits 32bits 64bits 32bits 64bits
Qt source link 4.6.3 4.6.3 4.6.3 (vs2008)
4.7.3 (vs2010)
Qt binary link 2010.05 2010.05 4.7.0 20010-05 4.6.3 (vs2008) -

Step1: Checkout slicer sources using subversion

For example:

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

Step2: Configure slicer project using either ccmake or cmake-gui

Recommended: Use cmake-gui to compile using default options If you downloaded the Qt binary then qmake 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 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, ./QT/qt-everywhere-opensource-src-4.7.3/bin/qmake.exe).

For linux/mac with ccmake:

mkdir Slicer4-SuperBuild
cd Slicer4-SuperBuild
ccmake -DQT_QMAKE_EXECUTABLE:FILEPATH=/home/myself/qt-4.6.3/qt/bin/qmake ../Slicer4

On linux and mac: for developers, set the CMAKE_BUILD_TYPE to Debug.

Note to Windows users 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 75 characters ( for example "c:\work\Slicer\Slicer-Superbuild" (32 characters) is fine)

Step3: Configure, Generate the solution files and Build

Two projects are generated by ccmake/cmake-gui: the top-level bin directory Slicer4-Superbuild and the subdirectory Slicer4-Superbuild/Slicer-build. The first project in Slicer4-Superbuild manages all the external dependencies of Slicer (VTK, ITK, Python, ...). To build Slicer 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.
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-Superuild/Slicer-build is necessary (the external libaries are considered built and up to date).
Warning, a lot of space disk is necessary to compile Slicer (>10GB on Windows)

  • Linux / Mac:

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


  • Windows:

Open Slicer4-SuperBuild\Slicer.sln (or Slicer-4.0\Slicer4-SuperBuild\Slicer-build\Slicer.sln) in Visual Studio and build the ALL_BUILD project.

Step 4

Run the launcher in Slicer4-SuperBuild/Slicer-build/Slicer (Slicer.exe on windows)

Platform Notes

  • Linux Ubuntu: if you have odd rendering artifacts, try disabling visual effects (System/Appearance/Visual Effects)