Running Qt application under wayland

myk picture myk · May 9, 2018 · Viewed 7.7k times · Source

Running:

./myapp -platform wayland

gives:

This application failed to start because it could not find or load the Qt platform plugin "wayland" in "".

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Reinstalling the application may fix this problem. Aborted (core dumped)

Following the instructions: How to build qtwayland?

Running qmake gives:

Running configuration tests... Done running configuration tests.

Configure summary: Qt Wayland Client ........................ no

Qt Wayland Compositor .................... no

Note: No wayland-egl support detected. Cross-toolkit compatibility disabled.

The qtwayland README indicates 2 dependencies:

  1. xkbcommon 0.2.0 - http://xkbcommon.org/
  2. wayland 1.6.0 - http://wayland.freedesktop.org/

On fedora 28, libxkbcommon is installed by default. In addition I also installed libxkbcommon-devel

 dnf whatprovides *wayland*

returns no results, although my gnome session is running under wayland.

I see I can download wayland from https://wayland.freedesktop.org/releases.html. I downloaded and decompressed 1.15, but not sure what to do with decompressed source: do I build it? do I need to put it somewhere where qtwayland can find it?

I see that the following file exists by default in fedora 28:

/usr/lib64/qt5/plugins/wayland-graphics-integration-server/libwayland-egl.so

But copying it to ~/Qt/5.10.1/gcc_64/plugins/platforms does not resolve my application startup errors.

Question: how to get my Qt application to run under wayland?


Added in response to bobbaluba questions below:

Am trying to build QtWayland against the official Qt Binaries because it is not included.

Installed wayland-devel as suggested, but qmake still reported no configure for Qt Wayland Client, as per the message above.

Tried to install qt5-qtwayland using dnf, which reported: Package qt5-qtwayland-5.10.1-2.fc28.x86_64 is already installed, skipping.

The following might be relevant:

? sudo dnf whatprovides libwayland-egl.so

Last metadata expiration check: 0:18:44 ago on Wed 09 May 2018 09:15:20 PM +08.

qt5-qtwayland-5.10.1-2.fc28.i686 : Qt5 - Wayland platform support and QtCompositor module

Repo : fedora

Matched from:

Provide : libwayland-egl.so

? find / -name libwayland-egl.so* -print

/usr/lib64/libwayland-egl.so

/usr/lib64/qt5/plugins/wayland-graphics-integration-server/libwayland-egl.so

? sudo ldconfig -p | grep wayland-egl

libwayland-egl.so.1 (libc6,x86-64) => /lib64/libwayland-egl.so.1

libwayland-egl.so (libc6,x86-64) => /lib64/libwayland-egl.so

Installed Qt 5.11.0rc which resulted in

~/Qt/5.11.0/gcc_64/plugins/wayland-graphics-integration-server/libwayland-egl.so

~/Qt/5.11.0/gcc_64/plugins/wayland-graphics-integration-server/libwayland-egl.so.debug

being added to ~/Qt/5.11.0/gcc_64/plugins/platforms.

cmake's CMakeFile.txt suddenly stopped working when I installed Qt5.11rc - with gcc unable to find Qt headers like QDate.

Tried compiling the example project 'addressbook' using Qt5.11 and got:

QSocketNotifier: Can only be used with threads started with QThread

Using Wayland-EGL

Using the 'xdg-shell-v6' shell integration

In short, using the Qt5.11rc seems to resolve the issue.

Answer

bobbaluba picture bobbaluba · May 9, 2018

Why does configuring QtWayland fail?

I'm assuming (correct me if I'm wrong) that you are trying to build QtWayland against official Qt binaries that do not include QtWayland.

Do you have development packages installed? In your case I think it should be wayland-devel.

Btw, the libwayland-egl.so you see, is your distro's version of the qt wayland-egl buffer integration (and not the same as the libwayland-egl.so dependency which qmake complains is missing). However, you should still be able to build QtWayland without wayland-egl, so I'm not sure what this is about.

Other options:

1. Use official QtWayland binaries

You are probably running into this problem because Qt packages did not previously include QtWayland.

However, starting with Qt 5.11.0 the official Qt binaries should include QtWayland, so the easiest thing would probably be to install Qt 5.11.0 or newer.

2. Use the distro's version of Qt (and Qt Wayland)

Install and use Qt from the distro, make sure you also install qtwayland (on Fedora I think it's qt5-qtwayland).