flatpak / libportal

libportal - Flatpak portal library
https://libportal.org
GNU Lesser General Public License v3.0
80 stars 39 forks source link

fatal error: qpa/qplatformintegration.h: No such file or directory #163

Closed nbolton closed 2 months ago

nbolton commented 2 months ago

When I compile libportal on Debian 13 against Qt 6.6.2, I get the following error:

INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /usr/bin/ninja -C /home/nick/Projects/synergy-1.16/build/meson
ninja: Entering directory `/home/nick/Projects/synergy-1.16/build/meson'
[92/112] Compiling C++ object subprojects/libportal/libportal/libportal-qt6.so.1.0.0.p/portal-qt6.cpp.o
FAILED: subprojects/libportal/libportal/libportal-qt6.so.1.0.0.p/portal-qt6.cpp.o 
c++ -Isubprojects/libportal/libportal/libportal-qt6.so.1.0.0.p -Isubprojects/libportal/libportal -I../../subprojects/libportal/libportal -Isubprojects/libportal -I../../subprojects/libportal -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sysprof-6 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/x86_64-linux-gnu/qt6/QtCore -I/usr/include/x86_64-linux-gnu/qt6 -I/usr/lib/x86_64-linux-gnu/qt6/mkspecs/linux-g++ -I/usr/include/x86_64-linux-gnu/qt6/QtCore/6.6.2 -I/usr/include/x86_64-linux-gnu/qt6/QtCore/6.6.2/QtCore -I/usr/include/x86_64-linux-gnu/qt6/QtGui -I/usr/include/x86_64-linux-gnu/qt6/QtGui/6.6.2 -I/usr/include/x86_64-linux-gnu/qt6/QtGui/6.6.2/QtGui -I/usr/include/x86_64-linux-gnu/qt6/QtWidgets -I/usr/include/x86_64-linux-gnu/qt6/QtWidgets/6.6.2 -I/usr/include/x86_64-linux-gnu/qt6/QtWidgets/6.6.2/QtWidgets -fvisibility=hidden -fdiagnostics-color=always -D_GLIBCXX_ASSERTIONS=1 -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -O0 -g -fPIC -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -pthread -std=c++17 -MD -MQ subprojects/libportal/libportal/libportal-qt6.so.1.0.0.p/portal-qt6.cpp.o -MF subprojects/libportal/libportal/libportal-qt6.so.1.0.0.p/portal-qt6.cpp.o.d -o subprojects/libportal/libportal/libportal-qt6.so.1.0.0.p/portal-qt6.cpp.o -c ../../subprojects/libportal/libportal/portal-qt6.cpp
../../subprojects/libportal/libportal/portal-qt6.cpp:32:10: fatal error: qpa/qplatformintegration.h: No such file or directory
   32 | #include <qpa/qplatformintegration.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[98/112] Generating subprojects/libportal/libportal/Xdp-1.0.gir with a custom command (wrapped by meson to set env)
../../subprojects/libportal/libportal/remote.h:152: Warning: Xdp: Couldn't find 'create_remote_desktop_session_full_finish' for the corresponding async function: 'create_remote_desktop_session_full'
[99/112] Compiling C++ object subprojects/libportal/tests/qt6/qt6-test.p/meson-generated_moc_test.cpp.o
ninja: build stopped: subcommand failed.

Here's my dpkg output:

$ dpkg -l | grep qt6-base-dev
ii  qt6-base-dev:amd64                                       6.6.2+dfsg-11                                           amd64        Qt 6 base development files
ii  qt6-base-dev-tools                                       6.6.2+dfsg-11                                           amd64        Qt 6 base development programs

I see that the file is in the qtbase project: https://github.com/qt/qtbase/blob/dev/src/gui/kernel/qplatformintegration.h

However, I do not appear to have the file on my computer:

$ find /usr/include/x86_64-linux-gnu/qt6 -name qwindow.h
/usr/include/x86_64-linux-gnu/qt6/QtGui/qwindow.h
$ find /usr/include/x86_64-linux-gnu/qt6 -name qplatformintegration.h
[no result]

Workaround 1: Disable backend-qt6

    subproject('libportal', default_options: ['backend-qt6=disabled'])

Workaround 2: Delete the code that fails

diff --git a/libportal/portal-qt6.cpp b/libportal/portal-qt6.cpp
index 129032d..a7f58f2 100644
--- a/libportal/portal-qt6.cpp
+++ b/libportal/portal-qt6.cpp
@@ -28,12 +28,6 @@
 #include <QBuffer>
 #include <QGuiApplication>

-#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
-#include <qpa/qplatformintegration.h>
-#include <private/qguiapplication_p.h>
-#include <private/qgenericunixservices_p.h>
-#endif
-
 static gboolean
 _xdp_parent_export_qt (XdpParent *parent,
                        XdpParentExported callback,
@@ -44,15 +38,6 @@ _xdp_parent_export_qt (XdpParent *parent,
     return FALSE;
   }

-#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
-  if (const auto services = dynamic_cast<QGenericUnixServices*>(QGuiApplicationPrivate::platformIntegration()->services()))
-    {
-      g_autofree char *handle = g_strdup(services->portalWindowIdentifier(w).toUtf8().constData());
-      callback (parent, handle, data);
-      return TRUE;
-    }
-#endif
-
   if (QGuiApplication::platformName() == QLatin1String("xcb"))
     {
       guint32 xid = (guint32) w->winId ();

Am I missing a -dev package or is there something else I'm doing wrong?

GeorgesStavracas commented 2 months ago

I think you need qt6-base-private-dev. But I don't use nor know much about Debian...

smcv commented 2 months ago

Yes, on Debian you need qt6-base-private-dev for this. (Or disable the Qt 6 binding.)

I uploaded libportal 0.8.0 to Debian unstable recently. It builds the Qt 6 binding, but does not yet install it (that will require adding extra package names, which needs archive administrator approval).

Ideally libportal would be able to get the window ID without using Qt internals, like it did by using libqt5x11extras5-dev for Qt 5, but that might not be possible in Qt 6.

smcv commented 2 months ago

If you're building libportal as a subproject of some larger project, you should disable all the backends that you aren't actively using.

GeorgesStavracas commented 2 months ago

@nbolton can you update us on if installing this package does the job for you?

nbolton commented 2 months ago

I think you need qt6-base-private-dev

Wonderful, that did the trick! Thanks for the help guys. It's hugely appreciated.

If you're building libportal as a subproject of some larger project, you should disable all the backends that you aren't actively using.

Yep, that worked too, thanks.

@whot Do you know if the qt6 backend is needed for Synergy? I can't see any mention of "qt" in PortalInputCapture.cpp or PortalRemoteDesktop.cpp so I added backend-qt6=disabled to our meson.build and it still seems to work fine. Edit: I'll close this since the original issue is resolved, but still curious to know if disabling the Qt backend is the right approach.

GeorgesStavracas commented 2 months ago

You would need backend-qt6 if you're using any method provided by portal-qt6.h, often that would be xdp_parent_new_qt.

nbolton commented 2 months ago

You would need backend-qt6 if you're using any method provided by portal-qt6.h, often that would be xdp_parent_new_qt.

Looks like we don't at the moment, as we only use remote desktop and input capture, but as we have a Qt GUI, perhaps we'll need some of those file functions in future when it's running as a Flatpak app.

GeorgesStavracas commented 2 months ago

Looks like we don't at the moment, as we only use remote desktop and input capture

Alright, so seems like you indeed do not need the backend for now.

perhaps we'll need some of those file functions in future when it's running as a Flatpak app

Sounds lovely! Let us know if you have any trouble or find any bugs when using them, the Qt integration is relatively new but seems to be doing well so far.