1.wsl ubuntu 22.04
2.linux 安装 sshd
apt-get install openssh-client;客户端
apt-get install openssh-server;服务端
wiindows也安装ssh客户端openssh 客户端
3.vim /etc/ssh/sshd_config:
PermitRootLogin yes
PasswordAuthentication yes
4.root进入wsl linux:
wsl –user root -d Ubuntu 2022
修改密码:passwd 输入两次
5.visual studio 2022
工具-》选项-》跨平台-》连接管理-》添加wsl的ssh连接信息,添加
6.wsl安装gdb
apt-get install gdb g++
检查VSCode的launch.json
文件中是否正确设置了GDB路径。以下是一个典型的launch.json
配置示例:
{
“version”: “0.2.0”,
“configurations”: [
{
“name”: “(gdb) Launch”,
“type”: “cppdbg”,
“request”: “launch”,
“program”: “${workspaceFolder}/a.out”,
“args”: [],
“stopAtEntry”: false,
“cwd”: “${workspaceFolder}“,
“environment”: [],
“externalConsole”: false,
“MIMode”: “gdb”,
“miDebuggerPath”: “/usr/bin/gdb”
}
]
}
其中,字段miDebuggerPath
应指向GDB可执行文件的路径。在大多数Linux系统中,默认路径为/usr/bin/gdb
。
7.!!!!最后运行产生的文件包括.out
等会保存在 ssh登录用户的home目录下projects
目录下,可以在项目 -> 属性 -> 远程生产根目录/项目目录处修改
注意配置类型,选择对应的!!!!,,这里选择应用程序.out

- 调试报错 : visual studio 2022 c++ wsl unable to start debugging.program path is misssing or invaild
Unable to start debugging. Program path … is missing or invalid. GDB failed with message:/home/zsy/projects/是一个目录
https://blog.csdn.net/m0_54442739/article/details/143633164
把这个将解决方案和项目放在同一目录中勾选: