Ubuntu 16.04 ROS Qt error: qt.qpa.plugin: Could not find the Qt platform plugin “xcb“ in ““

在运行ROS教程时遇到Ubuntu 16.04上的Qt错误:无法找到Qt平台插件“xcb”。问题源于Qt版本冲突,通过`locate libqxcb.so`定位文件,`export QT_DEBUG_PLUGINS=1`打印详细信息,最终发现是ROS_Q&A官网提及的环境变量设置导致,修改后问题解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题描述

运行ROS初始教程时,有个小乌龟的事例,rosrun turtlesim turtlesim_node,结果报错,如下所示:

qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

已放弃 (核心已转储)

但这我记得以前在其他机器上安装后也没出现上述问题,于是又只好百度+google

解决过程

这个是Qt的问题,错误信息简短,是说找不到Qt的一个插件,但感觉这个应该都已经安装好了,要不就在安装过程中集成好了,怎么会找不到?但我也确实不知道这个错误涉及的文件在哪。

1. locate libqxcb.so

ubuntu 16.04 Qt error: it could not find or load the Qt platform plugin "xcb"有一些相关的部分,但错误信息又不是很一致,值的庆幸的是拿到了locate libqxcb.so这个命令,看来xcb文件是与这个libqxcb.so文件错误有关,而这个命令输出结果如下:

/home/user/anaconda3/pkgs/qt-5.9.7-h5867ecd_1/plugins/platforms/libqxcb.so
/home/user/anaconda3/plugins/platforms/libqxcb.so
/home/user/webots/lib/webots/qt/plugins/platforms/libqxcb.so
/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so

前3条路径是用户也就是我创建的,最后一条是系统路径。这时起码排除了文件不存在的问题,应该是库路径出错了导致库找不到了(对应路径下确实存在文件),但我并不知道接下来该如何做,也没意识到可能导致的版本冲突问题。

2. export QT_DEBUG_PLUGINS=1

qt.qpa.plugin: Could not find the Qt platform plugin “xcb” in "/opt/Qt-5.12.4/plugins"这篇文章中提到可以使用export QT_DEBUG_PLUGINS=1来打印错误详细信息,这个可以在shell里面直接敲,不用加入.bashrc文件。确实,有更详细的调试信息才能更准确地解决问题。此时命令rosrun turtlesim turtlesim_node输出结果如下:

QFactoryLoader::QFactoryLoader() checking directory path "/opt/ros/kinetic/lib/turtlesim/platforms" ...
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

已放弃 (核心已转储)

但上述路径/opt/ros/kinetic/lib/turtlesim/platforms不存在,再者上述博客将export QT_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins/添加进

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值