QT:“无法找到Qt平台插件“xcb””。

6

出于学术目的,我安装了QT-everywhere 5.15开源版,但是运行程序失败了。

首先,我使用make编译了必要的源文件并安装了QT Creator,然后我选择在其中运行程序的qmake。当我尝试运行示例程序时,遇到了以下错误:

qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in "/usr/lib/x86-64-linux-gnu"
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.
The program has unexpectedly finished.
The process was ended forcefully.

我查看了/usr/lib/x86-64-linux-gnu,寻找xcb插件,并设置LD_LIBRARY_PATH=/usr/lib/x86-64-linux-gnu,但是同样的错误再次出现。

应该怎么做才能解决这个问题?


1
你可以尝试设置QT_DEBUG_PLUGINS=1获取更多信息。你是否有/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so?这是它应该在的地方。 - ypnos
@Voursstreds 在控制台上执行 QT_DEBUG_PLUGINS=1 /path/your/app。同时,指出您用于编译Qt的命令也是很好的。 - eyllanesc
当我将QT_QPA_PLATFORM_PLUGIN_PATH更改为/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms时,我收到了另一个错误,需要更长时间阅读。 - Voursstreds
@eyllanesc 应用程序实际上是什么?有一些插件在./qt-everywhere-src-5.15.0/qtbase/plugins中,我应该指向哪里? - Voursstreds
如果您尝试以root身份运行程序并收到“需要授权,但未指定授权协议”的错误,请考虑阅读此问题 - Matthias Braun
显示剩余6条评论
1个回答

7

1. 安装要求:

sudo apt install make g++ pkg-config libgl1-mesa-dev libxcb*-dev libfontconfig1-dev libxkbcommon-x11-dev python libgtk-3-dev
  • Python是可选的,用于QtQuick
  • libgtk-3-dev是可选的,如果您想要QtWidgets的GTK本地主题。

2. 配置:

./configure -opensource -confirm-license -nomake tests -nomake examples -prefix /path/to/install/dir

3. 编译:

make -j $(nproc)

make install

如果在新机器上构建Qt,很容易忘记安装XCB包。在构建过程中我没有遇到任何错误。以下是获取各种发行版的XCB包的命令的详细列表(请参见“Libxcb”部分):https://wiki.qt.io/Building_Qt_5_from_Git#Linux.2FX11 - Mitch
注意:安装完XCB依赖项后,您必须重新运行“configure”并添加“-recheck”参数。其输出应该显示“XCB Xlib ... yes”。 - Scott McPeak

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接