Qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found

Sorry for reopening closed issue:

I have the same problem which I can fix using:

unset QT_PLUGIN_PATH
unset QML2_IMPORT_PATH

However, I don’t know how can I incorporate it into my project, also I don’t know if unsetting those variables every time before running application is safe. This is my project:

user@nixos ~ > nix run gitlab:miro-zamiro/daikokuten
qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vkkhrdisplay, vnc, wayland-brcm, wayland-egl, wayland, xcb.

Aborted                    (core dumped) nix run gitlab:miro-zamiro/daikokuten
user@nixos ~ > unset QT_PLUGIN_PATH
user@nixos ~ > unset QML2_IMPORT_PATH
user@nixos ~ > nix run gitlab:miro-zamiro/daikokuten
button clicked
user@nixos ~ > 

Best,
Miro

1 Like

I’ve not done many qt builds, but you likely need to add the qt hook and plugins to your build inputs: Nixpkgs Reference Manual

I don’t know how that interacts with the python builder; there is an info block there that seems to suggest you need to manually wrap your scripts.

Thank you. I did some research and stumbled upon this:

At the bottom is described a very similar issue to mine. It suggests exporting QT_DEBUG_PLUGINS=1 and LD_DEBUG=libs. After exporting QT_DEBUG_PLUGINS=1 I found these lines:

qt.core.library: "/nix/store/9lf2mfhsk7s379mfsh8nqc4xabdg6dw6-qtbase-6.10.2/lib/qt-6/plugins/platforms/libqwayland.so" cannot load: Cannot load library /nix/store/9lf2mfhsk7s379mfsh8nqc4xabdg6dw6-qtbase-6.10.2/lib/qt-6/plugins/platforms/libqwayland.so: /nix/store/9lf2mfhsk7s379mfsh8nqc4xabdg6dw6-qtbase-6.10.2/lib/qt-6/plugins/platforms/../../../libQt6WaylandClient.so.6: undefined symbol: _ZN14QObjectPrivateC2E16QtPrivate_6_10_2, version Qt_6_PRIVATE_API
qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/nix/store/9lf2mfhsk7s379mfsh8nqc4xabdg6dw6-qtbase-6.10.2/lib/qt-6/plugins/platforms/libqwayland.so" : "Cannot load library /nix/store/9lf2mfhsk7s379mfsh8nqc4xabdg6dw6-qtbase-6.10.2/lib/qt-6/plugins/platforms/libqwayland.so: /nix/store/9lf2mfhsk7s379mfsh8nqc4xabdg6dw6-qtbase-6.10.2/lib/qt-6/plugins/platforms/../../../libQt6WaylandClient.so.6: undefined symbol: _ZN14QObjectPrivateC2E16QtPrivate_6_10_2, version Qt_6_PRIVATE_API"
qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.
qt.core.library: "/nix/store/9lf2mfhsk7s379mfsh8nqc4xabdg6dw6-qtbase-6.10.2/lib/qt-6/plugins/platforms/libqxcb.so" cannot load: Cannot load library /nix/store/9lf2mfhsk7s379mfsh8nqc4xabdg6dw6-qtbase-6.10.2/lib/qt-6/plugins/platforms/libqxcb.so: /nix/store/9lf2mfhsk7s379mfsh8nqc4xabdg6dw6-qtbase-6.10.2/lib/qt-6/plugins/platforms/../../../libQt6XcbQpa.so.6: undefined symbol: _ZN14QObjectPrivateC2E16QtPrivate_6_10_2, version Qt_6_PRIVATE_API
qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/nix/store/9lf2mfhsk7s379mfsh8nqc4xabdg6dw6-qtbase-6.10.2/lib/qt-6/plugins/platforms/libqxcb.so" : "Cannot load library /nix/store/9lf2mfhsk7s379mfsh8nqc4xabdg6dw6-qtbase-6.10.2/lib/qt-6/plugins/platforms/libqxcb.so: /nix/store/9lf2mfhsk7s379mfsh8nqc4xabdg6dw6-qtbase-6.10.2/lib/qt-6/plugins/platforms/../../../libQt6XcbQpa.so.6: undefined symbol: _ZN14QObjectPrivateC2E16QtPrivate_6_10_2, version Qt_6_PRIVATE_API"

After some more research with the help of Brave’s ai I gathered that there is some version mismatch so I checked my flake config and found that nixpkgs were pinned to fb7944c166a3b630f177938e478f0378e64ce108 (I have no idea why :innocent: ) but changing to unstable and updating flake.lock everything seems fine.

Thank you!!!

Side note: wrong wiki, use wiki.nixos.org.