C 语言

关注公众号 jb51net

关闭
首页 > 软件编程 > C 语言 > QT应用启动失败排查

QT应用启动失败排查方法小结

作者:samxfb

启动QT应用经常会碰到应用启动失败,qt platform plugin无法启动,本文就来介绍一下QT应用启动失败排查方法小结,具有一定的参考价值,感兴趣的可以了解以下

背景

启动QT应用经常会碰到应用启动失败,qt 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: xcb.

Aborted (core dumped)

排查办法

打开QT Plugin加载调试开关

export QT_DEBUG_PLUGINS=1

重新启动应用,会得到更详细的错误信息,如下

QFactoryLoader::QFactoryLoader() checking directory path "/home/netease/working/hermes/pc_mac/build/bin/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/home/netease/working/hermes/pc_mac/build/bin/plugins/platforms/libqxcb.so"
Found metadata in lib /home/netease/working/hermes/pc_mac/build/bin/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 "/home/netease/working/hermes/pc_mac/build/bin/platforms" ...
Cannot load library /home/netease/working/hermes/pc_mac/build/bin/plugins/platforms/libqxcb.so: (libxcb-xinput.so.0: cannot open shared object file: No such file or directory)
QLibraryPrivate::loadPlugin failed on "/home/netease/working/hermes/pc_mac/build/bin/plugins/platforms/libqxcb.so" : "Cannot load library /home/netease/working/hermes/pc_mac/build/bin/plugins/platforms/libqxcb.so: (libxcb-xinput.so.0: cannot open shared object file: No such file or directory)"
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: xcb.
Aborted (core dumped)

可以看出根本原因是Cannot load library /home/netease/working/hermes/pc_mac/build/bin/plugins/platforms/libqxcb.so: (libxcb-xinput.so.0: cannot open shared object file: No such file or directory)加载不了libqxcb.so, 依赖的动态库libxcb-xinput.so.0找不到, ldd查看如下:

[netease@netease-Precision-3630-Tower ~/working/hermes/pc_mac/build/bin]$ ldd /home/netease/working/hermes/pc_mac/build/bin/plugins/platforms/libqxcb.so
        linux-vdso.so.1 (0x00007ffc3330b000)
        libQt5XcbQpa.so.5 => /home/netease/working/hermes/pc_mac/build/bin/plugins/platforms/../../lib/libQt5XcbQpa.so.5 (0x00007fc35406c000)
        libQt5Gui.so.5 => /home/netease/working/hermes/pc_mac/build/bin/plugins/platforms/../../lib/libQt5Gui.so.5 (0x00007fc353800000)
        libQt5Core.so.5 => /home/netease/working/hermes/pc_mac/build/bin/plugins/platforms/../../lib/libQt5Core.so.5 (0x00007fc352b8f000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fc352806000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc352415000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc3521f6000)
        libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007fc351ff4000)
        libxcb-icccm.so.4 => /usr/lib/x86_64-linux-gnu/libxcb-icccm.so.4 (0x00007fc351def000)
        libxcb-image.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-image.so.0 (0x00007fc351bea000)
        libxcb-shm.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007fc3519e7000)
        libxcb-keysyms.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-keysyms.so.1 (0x00007fc3517e4000)
        libxcb-randr.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-randr.so.0 (0x00007fc3515d4000)
        libxcb-render-util.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-render-util.so.0 (0x00007fc3513d0000)
        libxcb-render.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007fc3511c3000)
        libxcb-shape.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shape.so.0 (0x00007fc350fbf000)
        libxcb-sync.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1 (0x00007fc350db8000)
        libxcb-xfixes.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-xfixes.so.0 (0x00007fc350bb0000)
        libxcb-xinerama.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-xinerama.so.0 (0x00007fc3509ad000)
        libxcb-xinput.so.0 => not found
        libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fc350675000)
        libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6 (0x00007fc35046d000)
        libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007fc350252000)
        libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fc35002a000)
        libxcb-xkb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-xkb.so.1 (0x00007fc34fe0e000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc34fa70000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fc34f858000)
        libGL.so.1 => /usr/lib/x86_64-linux-gnu/libGL.so.1 (0x00007fc34f5cc000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fc34f3c8000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fc35477b000)
        libxcb-util.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-util.so.1 (0x00007fc34f1c2000)
        libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fc34efbb000)
        libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007fc34eda6000)
        libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fc34eba2000)
        libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fc34e99c000)
        libGLX.so.0 => /usr/lib/x86_64-linux-gnu/libGLX.so.0 (0x00007fc34e76b000)
        libGLdispatch.so.0 => /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007fc34e4b5000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fc34e2ad000)

确实是 libxcb-xinput.so.0 => not found

解决办法

安装确实的三方库即可解决

sudo apt install libxcb-xinput-dev

 到此这篇关于QT应用启动失败排查方法小结的文章就介绍到这了,更多相关QT应用启动失败排查内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

您可能感兴趣的文章:
阅读全文