前言

今天在虚拟机上安装Ubuntu18.04 ,然后在线安装Qt5.15后,环境变量都设置了,发现启动QtCreator会报错,心酸啊,感觉好麻烦,所以记录下

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.
已放弃 (核心已转储)

问题

如下图:
linux ubuntu 安装5.15启动QtCreator报错_linux
报错信息如下:

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.

已放弃 (核心已转储)

首先启用debug报错信息打印

export QT_DEBUG_PLUGINS=1

如下图
linux ubuntu 安装5.15启动QtCreator报错_解决方案_02
会有详细报错

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


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


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


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


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


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


Got keys from plugin meta data ("vnc")
QFactoryLoader::QFactoryLoader() looking at "/usr/local/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so"
Found metadata in lib /usr/local/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "xcb"
        ]
    },
    "archreq": 0,
    "className": "QXcbIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/Qt/Tools/QtCreator/bin/platforms" ...
Cannot load library /usr/local/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: 无法打开共享对象文件: 没有那个文件或目录)
QLibraryPrivate::loadPlugin failed on "/usr/local/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /usr/local/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: 无法打开共享对象文件: 没有那个文件或目录)"
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.

解决方案:

安装如下库:

 apt-get install libxcb-xinerama0