Slicer3:Developers:Projects:QtSlicer/Tutorials/CompileWithQt
From Slicer Wiki
Home < Slicer3:Developers:Projects:QtSlicer < Tutorials < CompileWithQt
Contents
Building Slicer with Qt
1 Build Qt
Download and install Qt. As of winter 2009, get the 4.6 version.
- Linux/Mac - install full QtCreator package (use "-arch x86_64" for a 64 bit build on snowleopard)
cd Slicer3-lib mkdir Qt mkdir Qt-build cd Qt wget http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.6.0.tar.gz tar xvfz qt-everywhere-opensource-src-4.6.0.tar.gz cd qt-everywhere-opensource-src-4.6.0 echo yes | ./configure -prefix ../../Qt-build -debug-and-release -opensource -no-qt3support make -j 16 make install
On a 64 bit system, you may have to add -arch x86_64 to the Qt configure (?)
- Windows - need to get source code. On the LGPL tab, select the source code download page for windows and visual studio 2008, and note that there is a link below where you can download the source code in a zip archive (use a windows extracter, don't use cygwin unzip it).
- launch the msvc2008 command prompt (MSVC08 Tools->Visual Studio 2008 CommandPrompt)
- build with
configure.exe -platform win32-msvc2008
- Note: if you are compiling Slicer in Debug mode, please add the
-debug
argument to the command line above to generate a compatible build; Release is the default.- Using the Qt Designer on Windows requires that the Slicer widget plugins are compiled in the same mode than Qt. If Qt is compiled in Release mode (default), Slicer would have to be compiled in Release. However if Qt is compiled in Debug mode only, Slicer must be compiled in Debug. (and if Qt is in "Release and Debug", Slicer must be compiled in Release). So for developers, the Debug mode is recommended.
- According to [1] Qt does not support msvc2008 on windows xp. However, running configure.exe with no
-platform
argument seems to work. If you run configure with the-platform
argument first by mistake, and ifconfigure -clean
doesn't work, then you may need to start from a fresh extraction from the .zip archive before runningconfigure
again with no-platform
, unless you can runnmake
with the config clean target.
- Note: if you are compiling Slicer in Debug mode, please add the
- run
vcvars32.bat
first - and then
nmake
. - building with webkit support requires that src/3rdparty/webkit/WebCore/tmp/moc/{debug,release}_shared/mocinclude.tmp be removed. else you will get linker errors like
QNetworkReplyHandler.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall WebCore::FormDataIODevice::metaObject(void)const (?metaObject@FormDataIODevice@WebCore@@UBEPBUQMetaObject@@XZ)
- If you encounter the following error
api\qscriptextensionplugin.h(43): Error: Undefined interface,
, delete the files \src\script\tmp\moc\debug_shared\mocinclude.tmp and \src\script\tmp\moc\release_shared\mocinclude.tmp and restart nmake. For more info, please see QTBug 6470].
2 Build Slicer without Qt first
Do a standard build of Slicer and then we will convert it to use Qt
3 Build VTK with Qt enabled
cd ../../VTK-build ../CMake-build/bin/ccmake . Press 't' to enter advanced mode. VTK_USE_QT to ON Press 'c' to configure. DESIRED_QT_VERSION to 4 QT_QMAKE_EXECUTABLE to {path to}/Slicer3-lib/Qt-build/bin/qmake VTK_USE_QVTK_QTOPENGL to ON (advanced option) Press 'c' to configure. Press 'g' to generate make -j16
- issues
- if you encounter compilation errors like
undefined reference to `QMapData::createData(int)'
, delete the entire build directory (VTK-build) and start a build from scratch (you can use the same CMakeCache.txt) Make sure there is not a different Qt version in the PATH/LD_LIBRARY_PATH environment variables (ie Qt-4.6.0 while you try to compile VTK with 4.6.2).
- if you encounter compilation errors like
4 Download and build CTK
Preconditions
Git must be installed on your machine
- On Windows, you can download it here: http://code.google.com/p/msysgit
- On Ubuntu, you can install it using:
sudo apt-get install git git-core
Download CTK
cd /home/julien/work/Slicer3-lib/ it clone git://github.com/pieper/CTK.git CTK
Build CTK
mkdir CTK-build cd CTK-build ccmake ../CTK make -j16
5 Build Slicer with Qt enabled.
- Turn ON the option Slicer3_USE_QT
- Make sure
QT_QMAKE_EXECUTABLE
points to the qmake binary path (i.e. D:/work/Slicer3-lib/Qt-build/bin/qmake)
- Make sure
- Add the variable CTK_DIR:Path and make it points to the CTK build directory
- Using cmake-gui, click "Add Entry"
- Using ccmake, run
ccmake -DCTK_DIR:PATH=/home/julien/work/Slicer3-lib/CTK-build
- Using ccmake, run
cd ../../Slicer3-build ../Slicer3-lib/CMake-build/bin/ccmake -DCTK_DIR:PATH=/home/julien/work/Slicer3-lib/CTK-build .
Turn Slicer3_USE_QT ON Press 'c' to configure Set QT_QMAKE_EXECUTABLE to {path to}/home/julien/work/Slicer3-lib/Qt-build/bin/qmake Press 'c' to configure and then press 'g' to generate.
make -j16
Useful links for Qt
Troubleshooting
- Refresh problems of Qt widgets under linux
- Solution: turn Compiz off (System/Preferences/Appearance/Visual Effects)