测试环境deepin和windows
问题的另类描述
- linux下vs code配置c语言环境
- launch:program "xxxx" does not exist
- tasks.json和launch.json的关系
- 终端将被任务重用,按任意键关闭。
- [1] + Done "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-9liq8sx2.h8m" 1>"/tmp/Microsoft-MIEngine-Out-rs8nztsh.yr1"
对于新手来说,处理这类内容(两个json和那一堆参数)真的好难,把我的填坑记录下来,以供后人瞻仰。
配置vs code常见问题
Q1:tasks.json 和 launch.json的关系
在当前文件是C++的情况下,tasks可以被用来做编译,而launch用来执行编译好的文件
创建一个tasks.json文件告诉VS代码如何构建(编译)程序。
翻译:创建一个launch.json文件,以配置VS Code以在按F5调试程序时在WSL上启动GDB 。
Q2:launch:program "xxxx" does not exist
我发生这个错误的原因是因为tasks.json的"label"参数值和launch.json的"preLaunchTask"参数值不一致。
翻译:解决方法就是 让两者一致。我把他两的值都设为"build c program"
Q3:终端将被任务重用,按任意键关闭。
> Executing task: gcc -g -o main /home/yjc/Desktop/c/test/main.c <
终端将被任务重用,按任意键关闭。
正常现象
Q4:[1] + Done "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-9liq8sx2.h8m" 1>"/tmp/Microsoft-MIEngine-Out-rs8nztsh.yr1"
参考链接[Linux] Debug launch command shows up in terminal window
大致意思是,正常现象,没有办法隐藏
附上我的tasks.json和launch.json
tasks.json
{
"version": "2.0.0",
"tasks": [{
"label": "build c program",
"type": "shell",
"command": "gcc",
"args": [
"-g",
"-o",
"${fileBasenameNoExtension}",
"${file}"
]
}]
}
launch.json
{
"version": "0.2.0",
"configurations": [{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build c program",
}]
}
对标准内容做了很多删减,初学用不到怎么多内容
官方文档解读
这就很考验人的英语水平了。
官网文档地址Using C++ and WSL in VS Code
WSL是 Windows Subsystem for Linux 的缩写,因为window10中已经可以集成linux,只需要在microsoft store中搜索下载安装即可
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。