C++ (Qt 5.4.1) 此应用程序无法启动,因为它无法找到或加载 Qt 平台插件“xcb”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29405689/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
(Qt 5.4.1) This application failed to start because it could not find or load the Qt platform plugin "xcb"
提问by OrionNebular
I reinstalled my ubuntu 14.04 and Qt 5.4.1 and Qtcreator.
我重新安装了 ubuntu 14.04 和 Qt 5.4.1 以及 Qtcreator。
Qt 5.4.1 was built from source with "-opensource -nomake-test -nomake-example" configure options.
Qt 5.4.1 是使用“-opensource -nomake-test -nomake-example”配置选项从源代码构建的。
When I open an old project in QtCreator and build it everything's OK.
当我在 QtCreator 中打开一个旧项目并构建它时,一切正常。
But when I run this project it shows:
但是当我运行这个项目时,它显示:
This application failed to start because it could not find or load the Qt platform plugin "xcb".
Available platform plugins are: linuxfb, minimal, offscreen, xcb.
Reinstalling the application may fix this problem. Aborted (core dumped)
此应用程序无法启动,因为它无法找到或加载 Qt 平台插件“xcb”。
可用的平台插件有:linuxfb、minimal、offscreen、xcb。
重新安装应用程序可能会解决此问题。中止(核心转储)
So I googled this problem and tried everything. I installed every packages (libxcb series) but nothing can help!
所以我用谷歌搜索了这个问题并尝试了一切。我安装了所有软件包(libxcb 系列),但没有任何帮助!
Somebody help me please...
请有人帮助我...
I tried your methods.
你的方法我试过了。
When I run ldd
command in platform
directory, It shows:
当我ldd
在platform
目录中运行命令时,它显示:
You can see that nothing is missing. And actually I have made a softlink in the platform directory called libqxcb.so. There was no libqxcb.so in my platform directory before.
你可以看到什么都没有丢失。实际上我已经在名为 libqxcb.so 的平台目录中创建了一个软链接。之前我的平台目录中没有 libqxcb.so 。
And when I run ldd
command to my executable. it shows:
当我ldd
对可执行文件运行命令时。表明:
And you can see the error when I execute this file.
当我执行此文件时,您可以看到错误。
回答by BillyJoe
For a similar issue, in my case I solved with:
对于类似的问题,就我而言,我解决了:
export QT_PLUGIN_PATH=<qt base path>/plugins
回答by bweber
Try to go to the platforms
folder of the Qt installation your program is using and run ldd libqxcb.so
in a command prompt. Then check in the output if there are any missing dependencies. If the libqxcb.so
is missing one of its dependencies this produces the output you mentioned.
尝试转到platforms
您的程序正在使用的 Qt 安装文件夹并ldd libqxcb.so
在命令提示符下运行。然后检查输出是否有任何缺失的依赖项。如果libqxcb.so
缺少其依赖项之一,则会产生您提到的输出。
You can also use the ldd
command on your executable to check if there are any dependencies that can not be found.
您还可以在ldd
可执行文件上使用该命令来检查是否有任何无法找到的依赖项。
Here is an example of what missing dependencies look like in the ldd
output:
以下是ldd
输出中缺少的依赖项的示例:
PS: the accepted answer of thisquestion might also help you (creating a qt.conf file).
PS:这个问题的公认答案也可能对你有帮助(创建一个 qt.conf 文件)。
回答by frantic1048
I just stuck into a very similar issuefor hours, also nothing is "not found" in ldd
results on related executable, or libqxcb.so. finally I found it's the issue with the executable itself but not Qt. Tried QT_QPA_PLATFORM='' executable
and it works :)
我只是陷入了一个非常类似的问题几个小时,ldd
在相关可执行文件或 libqxcb.so 的结果中也没有“找不到” 。最后我发现这是可执行文件本身的问题,而不是 Qt。试过了QT_QPA_PLATFORM='' executable
,它有效:)
回答by Clive
'This application failed to start because it could not find or load the Qt platform plugin "xcb".'
“此应用程序无法启动,因为它无法找到或加载 Qt 平台插件“xcb”。”
See the accompanying web page, scroll down to heading "Qt Plugins". See first paragraph.
请参阅随附的网页,向下滚动到标题“Qt 插件”。见第一段。
libqxcb.so is required, even if you link the rest statically.
libqxcb.so 是必需的,即使您静态链接其余部分。
http://doc.qt.io/qt-5/linux-deployment.html#application-dependencies
http://doc.qt.io/qt-5/linux-deployment.html#application-dependencies
Qt have probably written their source code software to work in the following way: Instead of allowing libqxcb.so to be loaded at startup automatically (using rpath's) they use a dlopen() function to load it, as part of their QPA function set, soon after main() begins.
Qt 可能已经编写了他们的源代码软件以如下方式工作:而不是允许 libqxcb.so 在启动时自动加载(使用 rpath 的),他们使用 dlopen() 函数来加载它,作为他们 QPA 函数集的一部分, main() 开始后不久。
So this completely disregards our attempt to include all the "xcb" functions statically.
所以这完全无视我们尝试静态包含所有“xcb”函数。
If their dlopen() fails they just trot out their error message we all know and hate, and then call signal 6 to abort it (quite unnecessarily) instead of exiting normally.
如果他们的 dlopen() 失败了,他们只会抛出我们都知道和讨厌的错误消息,然后调用信号 6 中止它(非常不必要)而不是正常退出。
回答by jmarina
I got this exact error on linux xubuntu 18.04
我在 linux xubuntu 18.04 上遇到了这个确切的错误
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.
Aborted (core dumped)
First, defining this environment variable before starting qtcreator from the commandline causes more debug to be printed out:
首先,在从命令行启动 qtcreator 之前定义这个环境变量会导致打印出更多的调试信息:
export QT_DEBUG_PLUGINS=1
And then in the debug it said this when trying to start qtcreator from the commandline on xubuntu 18.04:
然后在调试中尝试从 xubuntu 18.04 上的命令行启动 qtcreator 时说:
Cannot load library /home/myuser/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)
Note that it cannot find libxkbcommon-x11, so the fix was this:
请注意,它找不到 libxkbcommon-x11,所以修复是这样的:
sudo apt-get install libxkbcommon-x11-dev
export PATH=$PATH:~/Qt/Tools/QtCreator/bin
Now qtcreator starts.
现在 qtcreator 启动。
回答by Alex
for anyone that hasn't found the solution yet and desperately looking for an answer, this is a copy of what @wardw commented on the currently top rated answer, which helped me resolve my underlying issue.
对于尚未找到解决方案并拼命寻找答案的任何人,这是@wardw 评论当前评分最高的答案的副本,它帮助我解决了我的根本问题。
export QT_DEBUG_PLUGINS=1
put this either in your run configuration or on the console before running your project and it will print more information about what is wrong.
在运行项目之前将其放在您的运行配置或控制台上,它将打印有关错误的更多信息。
回答by Dave
This might be obvious, but I got this error while running a GUI from a (displayless) SSH session [ Why? I was developing an embedded app on a much larger screen, right next to the tiny touch screen it is intended for ].
这可能很明显,但是我在从(无显示)SSH 会话运行 GUI 时遇到了这个错误 [ 为什么?我正在一个更大的屏幕上开发一个嵌入式应用程序,就在它打算用于的小触摸屏旁边]。
Anyhow, in bash the following command targeted the app to its own screen:
无论如何,在 bash 中,以下命令将应用程序定位到其自己的屏幕:
export DISPLAY=':0.0'
Hope this helps someone.
希望这可以帮助某人。
回答by wuqh
export QT_PLUGIN_PATH=<your qt installation path>/plugins/platforms
Similar to what mbjoe says, it really works!
与 mbjoe 所说的类似,它确实有效!
回答by ?m??ê? Mêddêb
Execute the command :
执行命令:
sudo ./app-name -platform linuxfb
须藤 ./app-name -platform linuxfb