You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Win11的Ubuntu22.04中运行ROS2 Humble turtlesim遇xcb显示错误求助

问题解决:WSL2 Ubuntu中ROS2 Humble运行turtlesim_node出现Qt xcb错误

错误信息

qt.qpa.xcb: could not connect to display
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.

解决步骤

  • 安装Windows端X服务器
    下载VcXsrv或Xming,启动时务必勾选「Disable access control」选项,确保WSL能连接到X服务器。

  • 配置WSL的DISPLAY环境变量

    • 临时生效:在终端执行以下命令
      export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
      
    • 永久生效:编辑~/.bashrc(使用zsh则编辑~/.zshrc),将上述命令添加到文件末尾,执行source ~/.bashrc使配置生效。
  • 安装缺失的Qt xcb依赖库
    在WSL终端执行:

    sudo apt update && sudo apt install libxcb-xinerama0 libxcb-cursor0
    
  • 验证运行
    重启终端后,重新执行ros2 run turtlesim turtlesim_node,turtlesim窗口应正常弹出。

内容的提问来源于stack exchange,提问作者PlaidTrack

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 04:03:15