用到wsl运行ros2 run turtlesim turtlesim_node报错
-
标题:无法用到wsl运行ros2 run turtlesim turtlesim_node
提问模板:
背景(可选):
问题描述:
[在这里详细描述您遇到的问题。请确保您提供了足够的背景信息,以便其他人能够理解您的问题。]
具体细节和上下文:
PS C:\Users\Administrator> wsl
xiangyang@DESKTOP-2KPADL6:/mnt/c/Users/Administrator$ ros2 run turtlesim turtlesim_node
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. [ros2run]: Aborted尝试过的解决方法:
从网上以及的deep seek搜索解决方法,感觉不行;也没太弄明白如何一步步操作
-
@1635731080 在Windows上安装X服务器
https://sourceforge.net/projects/vcxsrv/
配置VcXsrv(安装后操作):
启动XLaunch,配置选项: 选择"One large window" Display number设为0 勾选"Disable access control"(关键步骤) 其他保持默认
在WSL中设置环境变量:
echo "export DISPLAY=$(grep nameserver /etc/resolv.conf | awk '{print $2}'):0" >> ~/.bashrc source ~/.bashrc
安装Qt依赖库:
sudo apt update sudo apt install -y libxcb-xinerama0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xkb1