【问题标题】:C/C++ VS Code - Unable to start debugging. There was an error starting the pipe programC/C++ VS 代码 - 无法开始调试。启动管道程序时出错
【发布时间】:2019-10-05 22:36:00
【问题描述】:

我正在学习 Visual Studio Code C/C++ 调试工具,我正在按照教程 here 以及何时开始调试。我收到了这个错误。

我在 Ubuntu 上运行 WSL/Bash,并在 WSL 上安装了 gcc/g++ 和 gdb。

这是我在 launch.json 中的代码。非常感谢您的帮助。

{
"version": "0.2.0",
"configurations": [
  {
    "name": "(gdb) Launch",
    "type": "cppdbg",
    "request": "launch",
    "program": "/mnt/c/Users/myusername/Projects/CPP/helloworld/helloworld.out",
    "args": [""],
    "stopAtEntry": true,
    "cwd": "/mnt/c/Users/myusername/Projects/CPP/helloworld/",
    "environment": [],
    "externalConsole": true,
    "windows": {
      "MIMode": "gdb",
      "miDebuggerPath": "/usr/bin/gdb",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ]
    },
    "pipeTransport": {
      "pipeCwd": "",
      "pipeProgram": "C:\\Windows\\System32\\bash.exe",
      "pipeArgs": ["-c"],
      "debuggerPath": "/usr/bin/gdb"
    },
    "sourceFileMap": {
      "/mnt/c": "C:\\",
      "/usr": "C:\\Users\\myusername\\AppData\\Local\\Packages\\CanonicalGroupLimited.UbuntuonWindows79rhkp1fndgsc\\LocalState\\rootfs\\usr\\"
    }
  }
]
}

【问题讨论】:

  • WSL 中的>> ls /usr/bin/gdb 是否显示文件存在?
  • 是的,我刚刚访问了 WSL,输入了 cd usr、cd bin 和 ls gdb,它显示 gdb 确实存在

标签: c++ c bash visual-studio-code windows-subsystem-for-linux


【解决方案1】:

我遇到了同样的错误,终于让它工作了!

两个变化:

1) 在 pipeTransport 下,更改 pipeProgram: "pipeProgram": "bash.exe"

2) 在 SourceFileMap 下: 删除/usr

这是我的完整 launch.json 文件(只需将 USERNAME 替换为您的):

{
    "version": "0.2.0",
    "configurations": [

      {
        "name": "(gdb) Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": "/home/USERNAME/projects/helloworld/helloworld.out",
        "args": [""],
        "stopAtEntry": true,
        "cwd": "/home/USERNAME/projects/helloworld/",
        "environment": [],
        "externalConsole": true,
        "windows": {
          "MIMode": "gdb",
          "miDebuggerPath": "/usr/bin/gdb",
          "setupCommands": [
            {
              "description": "Enable pretty-printing for gdb",
              "text": "-enable-pretty-printing",
              "ignoreFailures": true
            }
          ]
        },
        "pipeTransport": {
          "pipeCwd": "",
          "pipeProgram": "bash.exe", 
          "pipeArgs": ["-c"],
          "debuggerPath": "/usr/bin/gdb"
        },
        "sourceFileMap": {
          "/mnt/c": "c:\\",
        }
      }
    ]
  }

【讨论】:

    猜你喜欢
    • 2016-09-21
    • 2022-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-17
    • 2018-02-22
    • 2018-11-20
    相关资源
    最近更新 更多