[vscode] launch:program xxx does not exist

测试环境deepin和windowslinux


问题的另类描述git

  • 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和那一堆参数)真的好难,把个人填坑记录下来,以供后人瞻仰。github

配置vs code常见问题

Q1:tasks.json 和 launch.json的关系

在当前文件是C++的状况下,tasks能够被用来作编译,而launch用来执行编译好的文件shell


1.png

建立一个tasks.json文件告诉VS代码如何构建(编译)程序。

2.png

翻译:建立一个launch.json文件,以配置VS Code以在按F5调试程序时在WSL上启动GDB 。

Q2:launch:program "xxxx" does not exist

我发生这个错误的缘由是由于tasks.json的"label"参数值和launch.json的"preLaunchTask"参数值不一致json

翻译:解决方法就是 让二者一致。我把他两的值都设为"build c program"windows

Q3:终端将被任务重用,按任意键关闭。

> Executing task: gcc -g -o main /home/yjc/Desktop/c/test/main.c <


终端将被任务重用,按任意键关闭。

正常现象测试

Build the programui

3.png

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 windowspa

大体意思是,正常现象,没有办法隐藏翻译


附上个人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中搜索下载安装便可

相关文章
相关标签/搜索