# Building slicer with system QT

**URL:** <https://discourse.slicer.org/t/building-slicer-with-system-qt/2710>\
**Category:** Development\
**Tags:** build\
**Created:** [April 26, 2018, 6:05pm UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710 "2018-04-26T18:05:27Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![vegoria](https://avatars.discourse-cdn.com/v4/letter/v/85f322/32.png) [@vegoria](https://discourse.slicer.org/u/vegoria)\
**Post date:** [April 26, 2018, 6:05pm UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710/1 "2018-04-26T18:05:27Z")

</div>

Hi,  
I’m trying to compile slicer for the first time - but when I try to compile QT webkit I get an error: conflicting declaration ‘typedef int32\_t UChar32’  
In manual I found information that I can use qt from system package, but when i try to compile it using:  
$CMAKE\_BIN -DCMAKE\_BUILD\_TYPE:STRING=Release -DQT\_QMAKE\_EXECUTABLE:FILEPATH=/usr/bin/qmake-qt4 …/Slicer-Source/Slicer  
I got an “missing QTOPENGL” error.  
I was searching in the Internet but I wasn’t able to find solution. Could anybody give me any advise/clue? Its third day and I made no progress in compilig it…

---

<div class="post-metadata">

**Author:** ![tavaughan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tavaughan/32/1475_2.png) [@tavaughan](https://discourse.slicer.org/u/tavaughan)\
**Post date:** [April 26, 2018, 6:21pm UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710/2 "2018-04-26T18:21:38Z")

</div>

Hi Sylwia,

You’re using Linux? I had issues in Ubuntu/Pop\_OS. You could try following the steps that I took and see if they help:

> [@Compile errors Pop!\_OS/Ubuntu with Qt 5.10](https://discourse.slicer.org/t/compile-errors-pop-os-ubuntu-with-qt-5-10/2576/21):
>
> I now have Slicer building and running without fiddling with LD\_LIBRARY\_PATH. I think the issue was with the Build-qt.sh script. Steps: Install Qt dependencies (for QtWebEngine-specific dependencies I referred to this page [https://wiki.qt.io/QtWebEngine/How\_to\_Try](https://wiki.qt.io/QtWebEngine/How_to_Try) ) Download the Qt-build script as per [https://github.com/jcfr/qt-easy-build/tree/5.10.0#readme](https://github.com/jcfr/qt-easy-build/tree/5.10.0#readme) Open the script in a text editor. Scroll to the configure step near the end of the file (line 365 at time of writing). Change the -no-rp…

Note that I built Qt5 using the qt-easy-build scripts, I did not try to use a system install of Qt.

Thomas

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [April 26, 2018, 7:46pm UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710/3 "2018-04-26T19:46:02Z")

</div>

Slicer developers [recommend](https://discourse.slicer.org/t/slicer-nightly-does-not-build-with-qt4-vtk7/2631/4) building against Qt5.

On my host running Arch Linux, the following configuration builds nicely :

> cmake -DSlicer\_VTK\_VERSION\_MAJOR:INT=9 -DQt5\_DIR:PATH=/usr/lib/cmake/Qt5 -DSlicer\_USE\_PYTHONQT\_WITH\_OPENSSL:BOOL=0 -DBUILD\_TESTING:BOOL=0 -DCMAKE\_BUILD\_TYPE:STRING=Release …/Slicer

You should adapt Qt5\_DIR parameter to your distribution.

If you really want Qt4, I guess you’ll be having a hard time and few help. In any case, Qt4 support is scheduled to be deprecated, as far as I understood.

---

<div class="post-metadata">

**Author:** ![vegoria](https://avatars.discourse-cdn.com/v4/letter/v/85f322/32.png) [@vegoria](https://discourse.slicer.org/u/vegoria)\
**Post date:** [April 26, 2018, 8:03pm UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710/4 "2018-04-26T20:03:09Z")

</div>

Ok, thanks 🙂 I’ll try to build it with Qt5 🙂

---

<div class="post-metadata">

**Author:** ![vegoria](https://avatars.discourse-cdn.com/v4/letter/v/85f322/32.png) [@vegoria](https://discourse.slicer.org/u/vegoria)\
**Post date:** [May 1, 2018, 2:04pm UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710/5 "2018-05-01T14:04:56Z")

</div>

Ok, I tried to compile slicer with Qt5. (I’m using linux mint).  
Configuration that I’m using to compile Slicer:

> $CMAKE\_BIN -DQT\_QMAKE\_EXECUTABLE:FILEPATH=/home/software/medical/slicer/Slicer-Build-Support/qt-everywhere-build-5.10.0/bin/qmake -DQt5\_DIR=/home/software/medical/slicer/Slicer-Build-Support/qt-everywhere-build-5.10.0/lib/cmake/Qt5 -DCMAKE\_BUILD\_TYPE:STRING=Release -DCMAKE\_PREFIX\_PATH:PATH=/home/software/medical/slicer/Slicer-Build-Support/qt-everywhere-build-5.10.0/bin/ -DSlicer\_USE\_PYTHONQT\_WITH\_TCL:BOOL=OFF -DSlicer\_USE\_SimpleITK:BOOL=OFF -DSlicer\_USE\_QtTesting:BOOL=OFF -DSlicer\_VTK\_VERSION\_MAJOR:STRING=9 -DSlicer\_VTK\_RENDERING\_BACKEND:STRING=OpenGL2 -DSlicer\_BUILD\_DataStore:BOOL=OFF …/Slicer-Source/Slicer/

But I get an error:

> Call Stack (most recent call first):  
> CMake/SlicerBlockFindQtAndCheckVersion.cmake:36 (find\_package)  
> CMake/SlicerBlockFindQtAndCheckVersion.cmake:110 (\_\_SlicerBlockFindQtAndCheckVersion\_find\_qt)  
> CMakeLists.txt:607 (include)
> 
> CMake Warning at CMake/SlicerBlockFindQtAndCheckVersion.cmake:36 (find\_package):  
> Found package configuration file:
> 
> ```
> /home/software/medical/slicer/Slicer-Build-Support/qt-everywhere-build-5.10.0/lib/cmake/Qt5/Qt5Config.cmake
> 
> ```
> 
> but it set Qt5\_FOUND to FALSE so package “Qt5” is considered to be NOT  
> FOUND. Reason given by package:
> 
> Failed to find Qt5 component “WebEngine” config file at  
> “/home/software/medical/slicer/Slicer-Build-Support/qt-everywhere-build-5.10.0/lib/cmake/Qt5WebEngine/Qt5WebEngineConfig.cmake”
> 
> Failed to find Qt5 component “WebEngineWidgets” config file at  
> “/home/software/medical/slicer/Slicer-Build-Support/qt-everywhere-build-5.10.0/lib/cmake/Qt5WebEngineWidgets/Qt5WebEngineWidgetsConfig.cmake”

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [May 1, 2018, 7:53pm UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710/6 "2018-05-01T19:53:02Z")

</div>

Try installing `libqt5webengine5` and probably `qt5webengine-dev`. I think Slicer requires at least Qt 5.7 (note the qt-easy-build script mentioned by tavaughan may be easier if the distribution version is too old).

---

<div class="post-metadata">

**Author:** ![vegoria](https://avatars.discourse-cdn.com/v4/letter/v/85f322/32.png) [@vegoria](https://discourse.slicer.org/u/vegoria)\
**Post date:** [May 10, 2018, 8:55am UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710/7 "2018-05-10T08:55:33Z")

</div>

How? By apt-get? Those packages does not exist.  
I’m installing qt5 using easy-build, but it does not compile web engine

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [May 10, 2018, 1:28pm UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710/8 "2018-05-10T13:28:03Z")

</div>

You need to install all of the dependencies [listed here](https://wiki.qt.io/QtWebEngine/How_to_Try#Installing_dependencies_on_Ubuntu). I built Qt 5.10 recently on Ubuntu 16.04 starting from those instructions. I don’t remember if they were complete, but [here are all the packages I installed to be able to compile](https://gist.github.com/ihnorton/bdce68c56344610f2ab071374e9b7908).

Unfortunately WebEngine is rather tricky to compile because the build system is layered in such a way that it does not give very good feedback during configuration about [why webengine was skipped](http://lists.qt-project.org/pipermail/interest/2018-April/029850.html).

---

<div class="post-metadata">

**Author:** ![vegoria](https://avatars.discourse-cdn.com/v4/letter/v/85f322/32.png) [@vegoria](https://discourse.slicer.org/u/vegoria)\
**Post date:** [October 7, 2018, 3:27pm UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710/9 "2018-10-07T15:27:09Z")

</div>

Ok, I’m returning to this old topic… Previously I managed to install Slicer with older version of Qt, but as I reinstalled my system and had to install Slicer again I decided to make it with Qt5.  
I’ve stuck again in this webengine installation… But when I tried to complie webkit separatelly I have a message:

“A suitable version of dbus could not be found.  
QtWebEngine will not be built.”

Anyone know which is this ‘suitable version’ of dbus and how to install it?  
When I’m makind apt-get dbus I receive message that dbus is already installed  
System: linux mint 19 Tara,  
Qt: using easy build script, so it is 5.10.0

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 7, 2018, 4:05pm UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710/10 "2018-10-07T16:05:49Z")

</div>

You should still be able to build Slicer with Qt4. We’ll probably remove Slicer’s QtWebEngine dependency shortly after releasing Slicer-4.10.

So, a solution can be to keep using Qt4 for now and switch to Qt5 when QtWebEngine is not needed for Slicer anymore (probably within a few months).

---

<div class="post-metadata">

**Author:** ![vegoria](https://avatars.discourse-cdn.com/v4/letter/v/85f322/32.png) [@vegoria](https://discourse.slicer.org/u/vegoria)\
**Post date:** [October 7, 2018, 4:38pm UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710/11 "2018-10-07T16:38:08Z")

</div>

Well I’m kind of stubborn person, and I’m irritated when I don’t know how to do something, so I would prefer to manage compile Slicer with Qt5 😉

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [October 7, 2018, 9:47pm UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710/12 "2018-10-07T21:47:44Z")

</div>

If you build against Qt5, do not pass QT\_QMAKE\_EXECUTABLE, only Qt5\_DIR.

---

<div class="post-metadata">

**Author:** ![vegoria](https://avatars.discourse-cdn.com/v4/letter/v/85f322/32.png) [@vegoria](https://discourse.slicer.org/u/vegoria)\
**Post date:** [October 8, 2018, 4:40am UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710/13 "2018-10-08T04:40:42Z")

</div>

Yes, but first I have to compile this version of Qt. When I try to compile qt4 on new linux distribution I get compilation errors. And when I try to compile qt5 I cannot compile webengine - some missing dependency probably, but I don’t know which dependency ☹

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [October 8, 2018, 12:04pm UTC](https://discourse.slicer.org/t/building-slicer-with-system-qt/2710/14 "2018-10-08T12:04:59Z")

</div>

To clarify, in you first message, you indicated that the command:

> [@vegoria](#):
>
> $CMAKE\_BIN   
> -DQT\_QMAKE\_EXECUTABLE:FILEPATH=/home/software/medical/slicer/Slicer-Build-Support/qt-everywhere-build-5.10.0/bin/qmake   
> -DQt5\_DIR=/home/software/medical/slicer/Slicer-Build-Support/qt-everywhere-build-5.10.0/lib/cmake/Qt5   
> -DCMAKE\_BUILD\_TYPE:STRING=Release   
> -DCMAKE\_PREFIX\_PATH:PATH=/home/software/medical/slicer/Slicer-Build-Support/qt-everywhere-build-5.10.0/bin/   
> -DSlicer\_USE\_PYTHONQT\_WITH\_TCL:BOOL=OFF   
> -DSlicer\_USE\_SimpleITK:BOOL=OFF   
> -DSlicer\_USE\_QtTesting:BOOL=OFF   
> -DSlicer\_VTK\_VERSION\_MAJOR:STRING=9   
> -DSlicer\_VTK\_RENDERING\_BACKEND:STRING=OpenGL2   
> -DSlicer\_BUILD\_DataStore:BOOL=OFF   
> …/Slicer-Source/Slicer/

failed with

> Failed to find Qt5 component “WebEngine” config file at  
> “/home/software/medical/slicer/Slicer-Build-Support/qt-everywhere-build-5.10.0/lib/cmake/Qt5WebEngine/Qt5WebEngineConfig.cmake”
> 
> Failed to find Qt5 component “WebEngineWidgets” config file at  
> “/home/software/medical/slicer/Slicer-Build-Support/qt-everywhere-build-5.10.0/lib/cmake/Qt5WebEngineWidgets/Qt5WebEngineWidgetsConfig.cmake”

could you instead try the following:

```auto
$CMAKE_BIN \
  -DQt5_DIR=/home/software/medical/slicer/Slicer-Build-Support/qt-everywhere-build-5.10.0/lib/cmake/Qt5 \
  -DCMAKE_BUILD_TYPE:STRING=Release \
  -DSlicer_USE_PYTHONQT_WITH_TCL:BOOL=OFF \
  -DSlicer_USE_SimpleITK:BOOL=OFF \
  -DSlicer_USE_QtTesting:BOOL=OFF \
  -DSlicer_BUILD_DataStore:BOOL=OFF \
  ../Slicer-Source/Slicer/

```

- The argument `QT_QMAKE_EXECUTABLE` should NOT be specified along with `Qt5_DIR`
- The argument `CMAKE_PREFIX_PATH` is not needed, the recommended way are to pass `Qt5_DIR` or `QT_QMAKE_EXECUTABLE`
- Passing `Slicer_VTK_RENDERING_BACKEND` or `Slicer_VTK_VERSION_MAJOR` are not needed, these will be automatically set based on `Qt5_DIR` or `QT_QMAKE_EXECUTABLE`
- Finally, make sure to run the configure command in a clean build directory

Last, could you also check that `Qt5WebEngineConfig.cmake` exists in your install of Qt5, if not make sure you select the corresponding component during installation. For example, see selected components [here](https://github.com/Slicer/SlicerBuildEnvironment/blob/1de3dc02b8ce96f9f132b0d7e45b95f17a646b2c/Docker/qt5-centos7/qt-installer-noninteractive.qs#L51-L54).
