qt.qpa.plugin:无法加载“”中的Qt平台插件“wayland”,即使已找到

ary*_*ary 9 qt qt5 ubuntu-20.04

我正在使用 Ubuntu 20.04.3 并尝试一些基于 QT 的应用程序。在我的特定用例中,我尝试启动 Android 文件传输,但它抛出以下错误:

    Failed to create wl_display (No such file or directory)
    qt.qpa.plugin: Could not load the Qt platform plugin "wayland" 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, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
Run Code Online (Sandbox Code Playgroud)

这是“qmake --version”的输出

    QMake version 3.1
    Using Qt version 5.9.7 in /home/*****/anaconda3/lib
Run Code Online (Sandbox Code Playgroud)

这是停用 conda 后得到的结果:

   QMake version 3.1
   Using Qt version 5.12.8 in /usr/lib/x86_64-linux-gnu
Run Code Online (Sandbox Code Playgroud)

另外,我尝试这样做:

    QT_QPA_PLATFORM=wayland
Run Code Online (Sandbox Code Playgroud)

这是“android-file-transfer export QT_DEBUG_PLUGINS=1”的输出

    QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms" ...
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so"
    Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so, metadata=
    {
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
    "Keys": [
        "eglfs"
    ]
},
"archreq": 0,
"className": "QEglFSIntegrationPlugin",
"debug": false,
"version": 330752}


    Got keys from plugin meta data ("eglfs")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqlinuxfb.so"
    Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqlinuxfb.so, metadata=
    {
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
    "Keys": [
        "linuxfb"
    ]
},
"archreq": 0,
"className": "QLinuxFbIntegrationPlugin",
"debug": false,
"version": 330752}


    Got keys from plugin meta data ("linuxfb")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimal.so"
    Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimal.so, metadata=
    {
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
    "Keys": [
        "minimal"
    ]
},
"archreq": 0,
"className": "QMinimalIntegrationPlugin",
"debug": false,
"version": 330752}


    Got keys from plugin meta data ("minimal")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimalegl.so"
    Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimalegl.so, metadata=
    {
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
    "Keys": [
        "minimalegl"
    ]
},
"archreq": 0,
"className": "QMinimalEglIntegrationPlugin",
"debug": false,
"version": 330752}


    Got keys from plugin meta data ("minimalegl")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqoffscreen.so"
    Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqoffscreen.so, metadata=
    {
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
    "Keys": [
        "offscreen"
    ]
},
"archreq": 0,
"className": "QOffscreenIntegrationPlugin",
"debug": false,
"version": 330752}


    Got keys from plugin meta data ("offscreen")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqvnc.so"
    Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqvnc.so, metadata=
    {
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
    "Keys": [
        "vnc"
    ]
},
"archreq": 0,
"className": "QVncIntegrationPlugin",
"debug": false,
"version": 330752}


    Got keys from plugin meta data ("vnc")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqwayland-egl.so"
    Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqwayland-egl.so, metadata=
    {
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
    "Keys": [
        "wayland-egl"
    ]
},
"archreq": 0,
"className": "QWaylandEglPlatformIntegrationPlugin",
"debug": false,
"version": 330752}


    Got keys from plugin meta data ("wayland-egl")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqwayland-generic.so"
    Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqwayland-generic.so, metadata=
    {
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
    "Keys": [
        "wayland"
    ]
},
"archreq": 0,
"className": "QWaylandIntegrationPlugin",
"debug": false,
"version": 330752}


    Got keys from plugin meta data ("wayland")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqwayland-xcomposite-egl.so"
    Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqwayland-xcomposite-egl.so, metadata=
    {
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
    "Keys": [
        "wayland-xcomposite-egl"
    ]
},
"archreq": 0,
"className": "QWaylandXCompositeEglPlatformIntegrationPlugin",
"debug": false,
"version": 330752}


    Got keys from plugin meta data ("wayland-xcomposite-egl")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqwayland-xcomposite-glx.so"
    Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqwayland-xcomposite-glx.so, metadata=
    {
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
    "Keys": [
        "wayland-xcomposite-glx"
    ]
},
"archreq": 0,
"className": "QWaylandXCompositeGlxPlatformIntegrationPlugin",
"debug": false,
"version": 330752}


    Got keys from plugin meta data ("wayland-xcomposite-glx")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so"
    Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so, metadata=
    {
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
    "Keys": [
        "xcb"
    ]
},
"archreq": 0,
"className": "QXcbIntegrationPlugin",
"debug": false,
"version": 330752}


    Got keys from plugin meta data ("xcb")
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ...
    loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqwayland-generic.so"
    Failed to create wl_display (No such file or directory)
    qt.qpa.plugin: Could not load the Qt platform plugin "wayland" 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, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
Run Code Online (Sandbox Code Playgroud)

这个问题正在影响我尝试使用的许多其他 GUI 应用程序,欢迎任何解决方案。

Ari*_* M. 2

根本原因应通过以下方式进行调试

$ export QT_LOGGING_RULES=qt.qpa.*=true
$ export QT_DEBUG_PLUGINS=1
$ export QSG_INFO=1
$ export QT_QPA_EGLFS_DEBUG=1    # or the appropiate
$ ./yourapp -platform wayland
Run Code Online (Sandbox Code Playgroud)

这里有更多细节

如果没有任何其他详细信息,最可能的原因似乎是指向一个设备并且不存在此类文件。这样的调试会告诉你错误在哪里,你应该记下错误并纠正它。其他原因可能是丢失或.so指向错误的文件。

您还可以尝试strace找到ltrace有问题的丢失文件。