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 ModulesOf 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.
- Download the latest available wheezy image from the Raspberry Pi website: http://www.raspberrypi.org/downloads.
- Uncompress the image and flash it to your SD card.
- Boot the new image on your board.
- 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.
- 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:
As a final note on this I have to say that scp has the somehow pleasant collateral effect of following the symlinks in libs.
Clone the qt5 git repo and start building the qtbase module:
$ git clone git://gitorious.org/qt/qt5.git
$ cd qt5
$ 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
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 :-)
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
$ make -jn
$ sudo make install
Repeat the same for the other two modules.
Building the QtWayland DependenciesThe 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:
Start the script and download from git the xkbcommon lib:
$ source env_setup.sh
$ git clone git://people.freedesktop.org/xorg/lib/libxkbcommon.git
$ cd libxkbcommon/
$ ./autogen.sh --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://anongit.freedesktop.org/wayland/wayland
$ cd wayland
$ ./autogen.sh --disable-documentation
$ 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
$ ./autogen.sh --host=arm-linux-gnueabihf --prefix=$RPI_SYSROOT$PREFIX --disable-scanner --disable-documentation
$ 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 http://qt.gitorious.org/qt/qtwayland
$ cd qtwayland
$ your_qt_prefix/qmake CONFIG+=wayland-compositor
$ 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 qtwayland.pro file still was failing, so I simlply removed the checks for xkbcommon and the rest of the build procedure succeeded.
CONFIG += config_xkbcommon
error(QtWayland requires Wayland 1.0.0 or higher)
error(QtWayland requires xkbcommon 0.2.0 or higher)
error(QtWayland requires wayland-scanner)
message("no wayland-egl support detected, cross-toolkit compatibility disabled");
Running Applications Using the QtWayland Platform PluginNow 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:
./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: http://elinux.org/RPiconfig.
Building QtWebKitFor 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 QtMultimediaQtMultimedia 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