Sunday, March 3, 2013

Bring up Qt 5 on Raspberry Pi with Wayland

Ok, I've been waiting to do this for quite some time but never had the time to actually do it. I tried this quickly twice but without success because of many issues. Now I invested some hours and made it to the end of the journey :-)
I therefore try to describe here the steps to make Qt 5.0.1 (the current version in the Qt git) on the new wheezy image with Wayland support.

Building the Qt Fundamental Modules

Of course the procedure is almost identical to the one used for Qt 5.0 that I described here. I only did a couple of things to speed up the process, you choose how to do it. I briefly describe here some of the steps.

  1. Download the latest available wheezy image from the Raspberry Pi website:
  2. Uncompress the image and flash it to your SD card.
  3. Boot the new image on your board.
  4. Install some libs that we will need (I won't compile the xcb platform plugin here, so in this case I decided not to install those xcb libs):

    $ sudo apt-get install libdbus-1-dev libudev-dev libssl-dev
    $ sudo apt-get install libasound2-dev
    $ sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libgstreamer-plugins-bad0.10-dev
    $ sudo apt-get install libffi-dev libpixman-1-dev
    $ sudo apt-get install libsqlite3-dev libicu-dev libfontconfig1-dev

    libdbus-1-dev is used to get the QtDBus module compiled from qtbase, libudev-dev to get udev support, libssl-dev for OpenSSL and libasound2-dev will provide Qt what it needs for ALSA support.
    GStreamer libs instead are mainly used in the qtmultimedia and qtwebkit modules. If the environment is setup correctly for gstreamer support, then the configure script will report the success.
    libffi-dev libpixman-1-dev are needed to compile the qtwayland module or its dependencies. libsqlite3-dev libicu-dev and libfontconfig1-dev instead are needed only if you intend to use QtWebKit.
  5. Instead of the loopback mount of the image on your system to get a correct sysroot, I quickly scp'ed the needed binaries from my board to a newly created sysroot. In particular I copied:
    • /lib
    • /usr/lib
    • /usr/include
    • /opt
    I'll refer to the directory containing all of this as rasp_sysroot. Quick and dirty. You might also consider using rsync though.
    As a final note on this I have to say that scp has the somehow pleasant collateral effect of following the symlinks in libs.
  6. Clone the qt5 git repo and start building the qtbase module:

    $ git clone git://
    $ cd qt5
    $ ./init-repository
    $ cd qt5/qtbase
    $ ./configure -prefix your_qt_prefix -release -device linux-rasp-pi-g++ \
    -make libs -device-option CROSS_COMPILE=your_toolchain_path/bin/arm-linux-gnueabihf- \
    -device-option DISTRO=wheezy -sysroot your_sysroot_path -opensource \
    -confirm-license -no-pch -make examples -nomake tests
    $ make -jn
    $ sudo make install

    In my case it was done automatically by the configure script, but you might need to set the pkgconfig path before running the configuration script:

    $ export PKG_CONFIG_PATH=your_sysroot_path/usr/lib/arm-linux-gnueabihf/pkgconfig
    $ export PKG_CONFIG_LIBDIR=yout_sysroot_path/usr/lib/pkgconfig:your_sysroot_path/usr/lib/arm-linux-gnueabihf/pkgconfig
    $ export PKG_CONFIG_SYSROOT_DIR=yout_sysroot_path

  7. During compilation I got an error indicating that it was impossible to find the header "vchost_config.h". I solved by editing the file in rasp_sysroot/opt/vc/include/interface/vmcs_host/vcgencmd.h:

    < #include "vchost_config.h"
    > #include "linux/vchost_config.h"

    This is not very elegant maybe... anyway it is sufficient. You might add an include path in the qmake.conf or similar, but it seemed good that way :-)
  8. At this point qtbase should have been successfully compiled. Now at least you should compile the qtscript, qtjsbackend and the qtdeclarative module:

    $ cd ..
    $ cd qtscript
    $ your_qt_prefix/bin/qmake
    $ make -jn
    $ sudo make install

    Repeat the same for the other two modules.

Building the QtWayland Dependencies

The xkbcommon and the wayland libraries must be cross-compiled before trying to build QtWayland. To do that first setup the environment; I used this script to do it:

export RPI_SYSROOT=your_sysroot_path
export TOOLCHAIN=your_toolchain_path
export QTDIR=your_qt_sources_dir/qtbase
export PREFIX=your_qt_prefix
export PKG_CONFIG_PATH="$RPI_SYSROOT/usr/lib/pkgconfig:$RPI_SYSROOT/$PREFIX/lib/pkgconfig:$RPI_SYSROOT/$PREFIX/share/pkgconfig"
export CPP=$TOOLCHAIN/bin/arm-linux-gnueabihf-cpp
export CC=$TOOLCHAIN/bin/arm-linux-gnueabihf-gcc
export CXX=$TOOLCHAIN/bin/arm-linux-gnueabihf-g++
export CFLAGS="--sysroot=$RPI_SYSROOT"
export CXXFLAGS="--sysroot=$RPI_SYSROOT"
export CPPFLAGS="--sysroot=$RPI_SYSROOT"
export LD=$TOOLCHAIN/bin/arm-linux-gnueabihf-ld
export LDFLAGS="--sysroot=$RPI_SYSROOT"
export AS=$TOOLCHAIN/bin/arm-linux-gnueabihf-as
export STRIP=$TOOLCHAIN/bin/arm-linux-gnueabihf-strip
export AR=$TOOLCHAIN/bin/arm-linux-gnueabihf-ar

Start the script and download from git the xkbcommon lib:

$ source
$ git clone git://
$ cd libxkbcommon/
$ ./ --prefix=some_prefix --host=arm-linux-gnueabihf
$ make && make install

Copy libs and headers resulting to your_sysroot_path.
Now before compiling the wayland library the wayland scanner is needed for the generation of C code from Wayland protocols. To compile this, open a new environment for standard compilation and start compiling the wayland-scanner and place it in the PATH:

$ git clone git://
$ cd wayland
$ ./ --disable-documentation
$ make
$ cp src/wayland-scanner $QTDIR/bin

Now get back to the cross-compilation environment and compile the wayland library itself:

$ cd wayland_dir
$ git clean -dxf
$ ./ --host=arm-linux-gnueabihf --prefix=$RPI_SYSROOT$PREFIX --disable-scanner --disable-documentation
$ make
$ sudo make install

Then, if necessary, copy the libraries into your sysroot.
Now let's build QtWayland:

$ export QT_WAYLAND_GL_CONFIG=brcm_egl
$ cd your_qt_sources_dir
$ git clone
$ cd qtwayland
$ your_qt_prefix/qmake CONFIG+=wayland-compositor
$ make
$ sudo make install

At this point I have to say I had issues during the execution of the qmake binary. Unfortunately I couldn't track down all the reasons, but it seems that libxkbcommon couldn't be found. According to the .pro file, the qtCompileTest function is used to check if config.test/xkbcommon can be built. Appearantly, the inclusion of X11/keysym.h couldn't be satisfied, and also it shouldn't be needed... but although the file can be compiled, the file still was failing, so I simlply removed the checks for xkbcommon and the rest of the build procedure succeeded.


CONFIG += config_xkbcommon


!config_wayland {
error(QtWayland requires Wayland 1.0.0 or higher)

#!config_xkbcommon {
error(QtWayland requires xkbcommon 0.2.0 or higher)

!config_wayland_scanner {
error(QtWayland requires wayland-scanner)

!config_wayland_egl {
message("no wayland-egl support detected, cross-toolkit compatibility disabled");

Running Applications Using the QtWayland Platform Plugin

Now copy the result of the build which should now be in your sysroot into your Pi and try to run the Wayland example compositor from QtWayland:

cd your_qt_prefix/examples/qtwayland/qml-compositor
export XDG_RUNTIME_DIR=/tmp
./qml-compositor -platform eglfs

At this point the server should be running. Now open another shell and try to run any Qt application using the wayland-brcm platform plugin:

$ cd your_app_path
$ ./your_app_bin -platform wayland-brcm &

Now you should see the window on the screen.
s It is possible however that some EGL/OpenGL error occurs, like eglCreatePixmapSurface failed: 3003, global image id: 0 0, then consider increasing the memory reserved to the GPU, that is a bad_allocation error. Simply add gpu_mem=n, where n is the number of MBs to assign to the GPU in the /boot/config.txt file. Read here for more information:

Building QtWebKit

For more details refer to this. It seems Qt guys have done a good work on QtWebKit. Making it work simply requires to build and run. Compile as said the qtwebkit module, then copy back the libraries to the device and load a WebView element.
The only thing that still seems to be missing is the 16bit color depth support: if you try tu run you might see a mess on the scren, that is because the QtWebProcess is writing 24bit image on 16bit mode. More details on this here.
Anyway, it seems now it is sufficient to set the framebuffer to 24bits to make it work:

$ fbset -depth 24

No need to modify the eglfs plugin anymore. The EGL configuration seems to correctly reflect the framebuffer color depth.

Building QtMultimedia

QtMultimedia is the module responsible for the multimedia content handling. For Linux, it is based on gstreamer, which is available, ad already said, for Raspberry Pi. Anyway, gstreamer relies on plugins to decode/render multimedia content, but most of those are clearly not hardware accelerated, which makes it nearly useless on an embedded platform for video playback.

Anyway, there is a plugin that is supposed to use the RPi accelerated OpenMAX libraries, gst-omx. I have to say I still have never seen it work well, so I'm not sure whether this is working or not on Pi. It is an interesting subject, but I don't if or when I'll get my hands on that.
I tried the QtMultimedia module a couple of times though, and I could play a couple of videos, but the result was clearly useless. Something like this should play the video (no audio):

import QtQuick 2.0
import QtMultimedia 5.0

Rectangle {

   width:  1920
   height: 1080

   color: "black"

   MediaPlayer {
      id: player
      source: "file://..."
      autoPlay: true


   VideoOutput {
      id: videoOutput
      source: player
      anchors.fill: parent



  1. Hi, yes QtMultimedia on Pi isn't quite there yet, and gst-omx would be showing some promise but recently it migrated to gstreamer1.0... and raspbian stable at least still rolls with 0.10 so gst-omx would require gstreamer 1.0 as well - that is why your other alternative - omxplayer libs - seemed more appealing. I've been trying to build your git sources but so far I've hit a few build errors - undefined references with OMXReader.o and OMXAudioCodec as well, on av_get_audio_channels I think.

  2. Thanks for the reference, I was wondering if it might be something like that - because this time around, Qt is on 5.0.2, Raspbian is on 2013-02-09 Wheezy and maybe that would all be related to the build issues...

    While attempting to create a Qt5 media player for the Pi, I think there are 2 main roads at the moment: Qt5 with omxplayer libraries, from your findings -or- Qt5 > gst-omx > GStreamer - and so far I believe that while the gst-omx approach would be the cleanest, it isn't quite at the same performance level as libomxplayer...

    Anyways, I would still like to see your approach working and improve upon it, so I will be working with it for now! Thank you for your support!

  3. Hi Guys, now I still follow trying compile qt5 and not have good news. I try so much guides and I not have good compilation.

    I follow this guide but I have not good end.

    Now I have the following problem:

    Project ERROR: Unknown module(s) in QT_PRIVATE: v8
    make[1]: *** [sub-qml-make_first-ordered] Error 3
    make[1]: se sale del directorio `/home/myuser/opt/qt5/qtdeclarative/src'
    make: *** [sub-src-make_first] Error 2

    In my dir prefix install qt5 /usr/local/qt5/mkspecs/modules/ i have "qt_lib_v8.pri" but not "qt_v8.pri"

    In my distro I have not the library "qt_v8.pri".

    I have looked at many similar errors but none gives me a solution and do not know where to look further.
    Someone could write more retail installation QT5 for raspberry??
    Someone could upload an ISO image of your full QT5 final distro installed??
    I do not know where to keep trying as I've never succeeded in installing (following many guides) QT5.

    Please I need to build a QTPlayer with omxplayer and webkit for a multimedia project.

    Thank a lots.

    1. Did you build and install the qtjsbackend module?

    2. Yes, I build and install the qtscript and qtjsbackend but qtdeclarative I can't build... why ???

    3. Sorry, never experienced that in any of the builds I've done. Try to inspect the .pro files and see why it is failing.

    4. Please could you tell me the basic steps and distros versions you used to install QT5 in raspberry??

      I'm using VirtualBox and Debian Squeeze 6.0.6-i386.


    5. The basic steps are described in the article. I used Ubuntu on vmware and on a real machine.

  4. I can also confirm that building the latest Qt5 (5.0.2) from git for the RPi is successful and the modules as well - make sure you are building the modules in the right order, because it matters, some depend on others for proper building.

    1. Well, today I try again build qt5. I hope to have good news.


  5. Hey guys, I've been trying to compile again set QT5 but I get an error "eglconvenience/qeglconvenience_p.h: 49:21: fatal error: EGL/egl.h: No such file or directory".

    I'm trying to compile QT5 and the module XCB and do not know if the reason for my error.

    I'll keep trying and hopefully achieve first, compile QT5 I need both.


    1. Check that your sysroot has EGL/egl.h in /opt/vc/include.

  6. Have you followed this guide >>

    Also, if XCB isn't a dead necessity for you (i.e. working with framebuffer alone, no desktop) - check out the bakeqtpi.bash script

    This is the configure line I'm using to cross compile Qt5 for the RPi:

    CONFIGURE_OPTIONS="-opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=$CROSSCOMPILER/bin/arm-linux-gnueabihf- -sysroot $ROOTFS -opensource -conf
    irm-license -optimized-qmake -release -make libs -prefix $QT5PIPREFIX -no-pch -nomake examples -nomake tests"

  7. Meanwhile, latest RPi image (2013-02-09-wheezy-raspbian), latest Qt5 git sources (5.0.2), installed a couple of dependency packages and got the thing running - great work, I will keep checking the code and if time allows, clean the 380+ warnings that are popping up - but for now I'll head on to QML goodness!

    I also tried the gstreamer1.0 + gst-omx approach but it still didn't work for me so far, some developments here:

    These guys built debian packages and an alternative repo for Raspbian, might worth checking out with time.

  8. I do not know what I'm doing wrong but I've never managed to compile QT5. I followed the guidelines to the letter but I always fail and I have never managed to finish a compilation of QT5. I search and search but still can not get good results.

    I've also tried to "" and other guidelines and also the script "bakeqtpi.bash" but I always fail.

    The truth is I do not know what is wrong with what I'm doing.

    I will continue testing other configurations and hope to have good results.

    My system is a "Debian Squeeze i386 6.0.7" with Virtual Box.

    Thank you again.

  9. Hello again, I have finally made ​​progress in the compilation of QT5, now I just need to build the module "qtdeclarative" but throws me the following error:

    Project ERROR: Unknown module (s) in QT_PRIVATE: v8
    make [1]: *** [sub-qml-make_first-ordered] Error 3
    make [1]: Leaving directory `/ home/usuario/opt/qt5/qtdeclarative/src '
    make: *** [sub-src-make_first] Error 2

    This has already happened to me before and I had not managed to solve and I now it has happened again but still can not find the solution.

    ¿Someone could help me? Please I need so much this.

    Thanks a lot.

    1. I had the same problem here and found a solution at
      I'm not sure why but somehow the configure in qtbase didn't set qtbase/bin/qt.conf correctly. Just change it to where qt5 should be installed as defined in your configure -prefix parameter.

      For me it worked

  10. How are you building the modules (which steps) and which modules and in which order?

  11. The order for build modules is : qtimageformats qtsvg qtjsbackend qtscript qtxmlpatterns qtdeclarative qtsensors qt3d qtgraphicaleffects.

    I've been following this guide "". This guide appears to me to compile the modules "qtsensors" and "qt3d" which are not likely to compile and I lower them in some branch of gitorius but I saw that there are important not named.

    I have not mentioned that my sysroot not the complete picture of my SD card but I only copied the required libraries as mentioned in your guide Luca Carlon "Bring up on Raspberry Pi Qt 5.0.1 with Wayland."

    Now I'm trying to compile QT5 in "ubuntu 12.10 x64" riding the full image of my SD card.

    The truth is that I've read so much about how to compile QT5 but I must be doing something wrong that I always fail. Many people say that it works and I follow the same guidelines that they do not want to run.

    I will not change the language used raspbian when configured in the RPI?? I've used "es_CL.UTF-8" and saw a guide that said to use the version "en_US.UTF-8".

    Well I hope to complete this great task so we can continue developing some applications I need.

    Thank you.

    1. You're missing qtbase, the first step of that guide you linked. Also, try qtscript before qtjsbackend.

    2. I had already built qmake and then I started with the other modules. I have undone the modules to compile in order but in VirtualBox (Debian 6.6 Squeeze i386) still does not work. On another computer with Ubuntu 12.10 x64, so far I have managed to compile everything "qtdeclarative" and continue with the remaining modules and I'll tell you as I have found everything.

      Thank you.

    3. Hello again, after trying to build QT5 I have been many advances. Now I'm building qtwayland but I have a problem I have not managed to solve. In this step (Building the QtWayland Dependencies) I am unable to build "qtwayland". I managed to build wayland but could not build "qtwayland" that the module was not QT5 sources so I had to download it from "". Despite this drawback had supposedly solved, when I want to build qtwayland gives me the error "Project ERROR: Wayland QtWayland Requires 1.0.3 or higher".

      I have rebuilt a lot of times with different "PREFIX" and other changes but the error is always the same.
      I do not know what else to do and so I turn to you again.
      Hopefully I can help.


    4. You're right... I forgot to specify to clone the qtwayland git. I added that.

      It seems that for some reason qmake is not finding the wayland lib. Place headers and libs in the correct position. Try to compile the test in config.test to have more information.

      If I could find a way to transfer, I could provide my image, but still I don't know how.

    5. To share the image you could use a server as,, etc. You can upload the compressed image in parts in rar and it should be fine.

      I will continue looking for ways to run my compilation.

  12. Hello, I have the same problem as the previous person: "Project ERROR: Wayland QtWayland Requires 1.0.3 or higher" and you answered to place headers and libs in the correct position. I would like to know what is the good position for libs and headers (can you tell me the path plz) ?

    Thank you in advance.

    1. Copy to your sysroot for instance. That way it should be found.

    2. I tried different prefix like /usr/local/, /mnt/rasp-pi-rootfs/usr/local, /mnt/rasp-pi-rootfs/usr/local/qt5pi (I use a mounted image of raspbian)etc but nothing works... any help about that ?
      Thank you in advance.

    3. Did you try to compile the test project as said in the post? Might give you some hints.

    4. I have bypass the Wayland version problem but i have another problem "no wayland-egl support detected, cross-toolkit compatibility disabled" and when I simply removed the checks of wayland_egl in .pro file and I try to do the "make" I have some fatal error like "fatal error: qwayland-windowmanager.h: No such file or directory" or "fatal error: qwayland-wayland.h":No such file or directory" (I haven't found these headers on my computer). Do you have any idea ?

    5. I think qwayland-wayland.h may be generated by qtwaylandscanner, but the lack of documentation makes it hard to tell. I can't get qtwaylandscanner to compile against Qt 5.0.2, so I can't get past this step.

  13. Hello Luca, hello everyone

    just a question from a beginner in Qt for remote cross-compiling:
    I would like to have Qt4 on raspberry and being able to remote cross-compile and remote debugging from a host pc; just exactly what you describe here, but simply from Qt4 and not Qt5 (since I don't need it: and it seems to me that Qt4 is much more mature for raspberry than Qt5).

    I successfully managed to install Qt4 + QtDesigner locally on Raspberry (very easy), but now I wonder how to set up the QtDesigner and the cross-compiler and gdb on the host PC... I never did it and I don't know where to start; would you have any recommendation?

    any tip is much appreciated!
    thanks a lot

    1. On the contrary, for Raspberry Pi, Qt5 seems to be the most mature. I don't even know what is supported for Qt4 on Pi. Read the wiki of the Qt project: Last paragraph. Why using something that has been outdated for more than 6 months?

      As for gdb, you might start from the manual in the toolchain... seems pretty reasonable... If you're using the linaro toolchain look here:

  14. Hello Luca,
    I have cross-compiled Qt5 following your instructions.

    Unfortunately I have an error when I try to run the compiled program on the raspberry:

    "Illegal Instruction"

    I cannot fix it. Do you have any idea to solve it?

    Thank you

    1. Is it actually built for arm?

    2. I used the linaro gcc cross compiler you have wrote about in your first document

      I used gdb to test the application on the raspberry and the gdb result was that the app is compiled with arm-linux-gnuaebihf

    3. I used also the "file" command and the response is:
      ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x0e7dd2b5a3dc8286c1b5af7756e77812b7c13e7e, not stripped

    4. Then maybe a bug in your code? Or maybe something wrong with the Qt libs you built? Sorry, too few information.

    5. The app is the Helloworld from the qt-project web site.

    6. Then try to debug and see when it crashes or try with a non Qt based application (i.e. do not link to Qt using qmake).

  15. ็Hi guy. Someone can help me? (when i compile qt5 i got this)

    /mkspecs/devices/linux-rasp-pi-g++/qeglfshooks_pi.cpp:195:10: warning: unused parameter ‘window’ [-Wunused-parameter]
    make[4]: *** [.obj/release-shared/qeglfshooks_pi.o] Error 1
    make[4]: Leaving directory `/home/host/raspberry/qt-everywhere-opensource-src-5.1.1/qtbase/src/plugins/platforms/eglfs'
    make[3]: *** [sub-eglfs-make_first] Error 2
    make[3]: Leaving directory `/home/host/raspberry/qt-everywhere-opensource-src-5.1.1/qtbase/src/plugins/platforms'
    make[2]: *** [sub-platforms-make_first] Error 2
    make[2]: Leaving directory `/home/host/raspberry/qt-everywhere-opensource-src-5.1.1/qtbase/src/plugins'
    make[1]: *** [sub-plugins-make_first] Error 2
    make[1]: Leaving directory `/home/host/raspberry/qt-everywhere-opensource-src-5.1.1/qtbase/src'
    make: *** [sub-src-make_first] Error 2

    Thx you.

    1. Report the actual error, not just the message "Error"...

    2. Why i can't cross compile?

      and missing qmake

    3. Difficult to say if you don't post the error.

    4. my error like this:

    5. Sorry, I don't remember encountering something like that.

    6. Edit qtbase/mkspecs/devices/linux-rasp-pi-g++/qeglfshooks_pi.cpp and cast the 9th argument to DISPMANX_TRANSFORM_T on line 133.

      Also comment out the declaration of vc_dispmanx_element_change_attributes couple of lines above.

    7. Interesting! Since when this is needed? I never needed to fix that. Maybe with the latest Raspbian?

  16. Hi I followed above steps, and now Im able launch all application using wayland-brcm platform, But im when i launch opengl examples like hellowindow with wayland-brcm platform , the opengl app hellowindow is not launching as expected like when we launch with eglfs platform.

    ./qmlcompositor -platform eglfs& (its working fine)

    ./wiggly -platform wayland-brcm (working fine)

    opengl/hellowindow/hellowindow -platform wayland-brcm (not working)

    nothing coming

    stoping at ..

    so whats the reason for this ? But here its working fine

    1. QtWayland was broken multiple times, so you might ask QtWayland guys about this.

  17. When i launch opengl apps it launches but unable display or render on screen, Then it seems that opengl application will not have support in qtwayland??? or Im missing any configuration?

  18. Should I compile Qt like your way. There are qt5 packages in archLinuxArm. If I use these packages, can I use your library

    1. At least the qt multimedia module yes, as there modifications to be applied.

  19. Does QtWayland work with Raspbian Jessie?
    I just tried to native compile the QtWayland module and got the following error from qmake CONFIG += wayland-compositor:

    Project WARNING: No xkbcommon 0.2.0 or higher found, disabling support for it

    If I comment out the check for xkbcommon like you showed, the module builds without error but when making the qml compositor example I get this error:

    Project ERROR : Unknown Modules(s) in QT: Compositor

    1. I'm sorry, I haven't used this module since 2013 so I have no idea.