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.

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:

/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.

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:
33c33

< #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:

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:

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.

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 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):

55 comments:

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.

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!

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.

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.

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:

http://www.raspberrypi.org/phpBB3/viewtopic.php?t=34250&p=293243

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

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 "http://qt-project.org/wiki/RaspberryPi_Beginners_guide" 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.

I had the same problem here and found a solution at http://www.mail-archive.com/interest@qt-project.org/msg04497.htmlI'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.

I've been following this guide "https://gitorious.org/raspberry-qt/raspberry-qt/blobs/master/README.txt". 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.

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.

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 "http://qt.gitorious.org/qt/qtwayland". 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.

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) ?

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.

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 ?

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.

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?

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: http://qt-project.org/wiki/RaspberryPi. 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: https://github.com/raspberrypi/tools/tree/master/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/share/doc/gcc-linaro-arm-linux-gnueabihf-raspbian/html/gdb.

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

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 ..Brcm-EGL

so whats the reason for this ? But here its working fine http://www.youtube.com/watch?v=HItv4HX5r3k&list=UUznZH9PHUe2L4WxvPAXPPSA&index=3