CLion 与 WSL 尝试运行 QT 应用程序(无法加载 xcb)

CLion 与 WSL 尝试运行 QT 应用程序(无法加载 xcb)

我正在尝试从这里运行代码https://github.com/vt4a2h/uml-tool我发现自己被这个错误信息困住了:

qt.qpa.xcb: could not connect to display 
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, vnc, xcb.

我使用的是 Windows 10 和 WSL 2(Ubuntu 20.04.2 LTS)

我尝试过的:

  • sudo apt-get install -y xserver-xorg xinit
  • sudo apt-get install -y mesa-utils libegl1-mesa libegl1-mesa-dev libgbm-dev libgbm1 libgl1-mesa-dev libgl1-mesa-dri libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
  • /etc/X11/xorg.conf --->-bash:/etc/X11/xorg.conf:没有此文件或目录
  • sudo Xorg-configure
X.Org X Server 1.20.9
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.15.0-130-generic x86_64 Ubuntu
Current Operating System: Linux NB-CJ-U4-5336 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64
Kernel command line: initrd=\initrd.img panic=-1 pty.legacy_count=0 nr_cpus=12
Build Date: 17 January 2021  09:13:31AM
xorg-server 2:1.20.9-2ubuntu1.2~20.04.1 (For technical support please see http://www.ubuntu.com/support)
Current version of pixman: 0.38.4
       Before reporting problems, check http://wiki.x.org
       to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
       (++) from command line, (!!) notice, (II) informational,
       (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Tue Mar 16 17:32:21 2021
List of video drivers:
       amdgpu
       ati
       intel
       nouveau
       qxl
       radeon
       vmware
       modesetting
       fbdev
       vesa
No devices to configure.  Configuration failed.
(EE) Server terminated with error (2). Closing log file.
  • sudo apt-get install --重新安装 libxcb-xinerama0
  • 导出 QT_DEBUG_PLUGINS=1

我还尝试将以下内容添加到环境中:

QT_DEBUG_PLUGINS=1
QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/
XAUTHORITY=~/.Xauthority

我的新错误信息是:

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/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/lib/x86_64-linux-gnu/qt5/plugins" ...
QFactoryLoader::QFactoryLoader() checking directory path "/mnt/c/MyPrograms/uml-tool/cmake-build-debug" ...
QFactoryLoader::QFactoryLoader() looking at "/mnt/c/MyPrograms/uml-tool/cmake-build-debug/cmake_install.cmake"
QElfParser: '/mnt/c/MyPrograms/uml-tool/cmake-build-debug/cmake_install.cmake' is not an ELF object
"'/mnt/c/MyPrograms/uml-tool/cmake-build-debug/cmake_install.cmake' is not an ELF object" 
         not a plugin
QFactoryLoader::QFactoryLoader() looking at "/mnt/c/MyPrograms/uml-tool/cmake-build-debug/CMakeCache.txt"
QElfParser: '/mnt/c/MyPrograms/uml-tool/cmake-build-debug/CMakeCache.txt' is not an ELF object
"'/mnt/c/MyPrograms/uml-tool/cmake-build-debug/CMakeCache.txt' is not an ELF object" 
         not a plugin
QFactoryLoader::QFactoryLoader() looking at "/mnt/c/MyPrograms/uml-tool/cmake-build-debug/Makefile"
QElfParser: '/mnt/c/MyPrograms/uml-tool/cmake-build-debug/Makefile' is not an ELF object
"'/mnt/c/MyPrograms/uml-tool/cmake-build-debug/Makefile' is not an ELF object" 
         not a plugin
QFactoryLoader::QFactoryLoader() looking at "/mnt/c/MyPrograms/uml-tool/cmake-build-debug/uml-tool"
"Failed to extract plugin meta data from '/mnt/c/MyPrograms/uml-tool/cmake-build-debug/uml-tool'" 
         not a plugin
QFactoryLoader::QFactoryLoader() looking at "/mnt/c/MyPrograms/uml-tool/cmake-build-debug/UmlTool.cbp"
QElfParser: '/mnt/c/MyPrograms/uml-tool/cmake-build-debug/UmlTool.cbp' is not an ELF object
"'/mnt/c/MyPrograms/uml-tool/cmake-build-debug/UmlTool.cbp' is not an ELF object" 
         not a plugin
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/platforms/libqeglfs.so"
Got keys from plugin meta data ("eglfs")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/platforms/libqlinuxfb.so"
Got keys from plugin meta data ("linuxfb")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/platforms/libqminimal.so"
Got keys from plugin meta data ("minimal")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/platforms/libqminimalegl.so"
Got keys from plugin meta data ("minimalegl")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/platforms/libqoffscreen.so"
Got keys from plugin meta data ("offscreen")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/platforms/libqvnc.so"
Got keys from plugin meta data ("vnc")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/platforms/libqxcb.so"
Got keys from plugin meta data ("xcb")
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"
Got keys from plugin meta data ("eglfs")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqlinuxfb.so"
Got keys from plugin meta data ("linuxfb")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimal.so"
Got keys from plugin meta data ("minimal")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimalegl.so"
Got keys from plugin meta data ("minimalegl")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqoffscreen.so"
Got keys from plugin meta data ("offscreen")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqvnc.so"
Got keys from plugin meta data ("vnc")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so"
Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/mnt/c/MyPrograms/uml-tool/cmake-build-debug/platforms" ...
loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so"
qt.qpa.xcb: could not connect to display 
qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/" 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 (from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/), linuxfb (from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/), minimal (from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/), minimalegl (from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/), offscreen (from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/), vnc (from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/), xcb (from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/), eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.


Process finished with exit code 134

以上所有命令均从 ubuntu 控制台运行

我该怎么办?如何修复这个问题?

相关内容