ubuntu安装qt5 Could not load the Qt platform plugin "xcb" in "" even though it was found.

百度了好久都没有发现能够解决问题的方法,终于,综合了好几篇博客,得出了如下的解决方法。
Ubuntu安装qt5,启动qtcreator的时候报错,错误如下

This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Reinstalling the application may fix this problem.
Aborted (core dumped)

解决方法:
1.sudo gedit ~/.bashrc 输入 export QT_DEBUG_PLUGINS=1
2.运行qtcreator,在命令行得到运行中过程,如下

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


Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/opt/Qt5.10.0/Tools/QtCreator/bin/platforms" ...
Cannot load library /opt/Qt5.10.0/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (/usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: version `Qt_5_PRIVATE_API' not found (required by /opt/Qt5.10.0/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so))
QLibraryPrivate::loadPlugin failed on "/opt/Qt5.10.0/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /opt/Qt5.10.0/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (/usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: version `Qt_5_PRIVATE_API' not found (required by /opt/Qt5.10.0/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so))"
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Reinstalling the application may fix this problem.
Aborted (core dumped)

3.原因在于libqxcb.so,cd到/opt/Qt5.10.0/5.10.0/gcc_64/plugins/platforms,运行命令ldd libqxcb.so,查看关联内容,如下:

./libqxcb.so: /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: version `Qt_5_PRIVATE_API' not found (required by ./libqxcb.so)
./libqxcb.so: /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5: version `Qt_5_PRIVATE_API' not found (required by ./libqxcb.so)
./libqxcb.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.10' not found (required by ./libqxcb.so)
./libqxcb.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5' not found (required by ./libqxcb.so)

4.终于百度version `Qt_5_PRIVATE_API’ not found,需要添加环境变量,如下

export LD_LIBRARY_PATH=/opt/Qt5.10.0/5.10.0/gcc_64/lib:$LD_LIBRARY_PATH

并且source ~/.bashrc激活设置内容
5.终于运行qtcreator成功

  • 11
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值