【问题标题】:I get an error saying " Could not find the task 'C/C++: g++.exe build active file'我收到一条错误消息:“找不到任务 \'C/C++: g++.exe build active file\'
【发布时间】:2022-08-18 11:11:04
【问题描述】:

我在 Stack Overflow 上尝试过大多数事情,包括弄乱外部控制台值、使用以前版本的 C/C++ 扩展、将 cppbuild 更改为 shell 等。似乎没有什么能使它工作。如果我仍然按调试,我会收到一条错误消息,指出启动程序 \'....launch.exe\' 不存在。

这是我的launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    \"version\": \"0.2.0\",
    \"configurations\": [
      {
        \"name\": \"g++.exe - Build and debug active file\",
        \"type\": \"cppdbg\",
        \"request\": \"launch\",
        \"program\": \"${fileDirname}\\\\${fileBasenameNoExtension}.exe\",
        \"args\": [],
        \"stopAtEntry\": false,
        \"cwd\": \"C:\\\\msys64\\\\mingw64\\\\bin\",
        \"environment\": [],
        \"externalConsole\": false,
        \"MIMode\": \"gdb\",
        \"setupCommands\": [
          {
            \"description\": \"Enable pretty-printing for gdb\",
            \"text\": \"-enable-pretty-printing\",
            \"ignoreFailures\": true
          }
        ],
        \"preLaunchTask\": \"C/C++: g++.exe build active file\",
        \"miDebuggerPath\": \"C:\\\\msys64\\\\mingw64\\\\bin\\\\gdb.exe\"
      }
    ]
  }

这是我的task.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    \"version\": \"2.0.0\",
    \"tasks\": [
      {
        \"type\": \"shell\",
        \"label\": \"C/C++: gcc.exe build active file\",
        \"command\": \"C:\\\\msys64\\\\mingw64\\\\bin\\\\gcc.exe\",
        \"args\": [
          \"-fdiagnostics-color=always\",
          \"-g\",
          \"${file}\",
          \"-o\",
          \"${fileDirname}\\\\${fileBasenameNoExtension}.exe\"
        ],
        \"options\": {
          \"cwd\": \"${workspaceFolder}\"
        },
        \"problemMatcher\": [
          \"$gcc\"
        ],
        \"group\": {
          \"kind\": \"build\",
          \"isDefault\": true
        },
        \"detail\": \"compiler: C:\\\\msys64\\\\mingw64\\\\bin\\\\gcc.exe\"
      },
      {
        \"label\": \"run make\",
        \"type\": \"shell\",
        \"command\": \"make\"
      },
      {
        \"label\": \"run make test\",
        \"type\": \"shell\",
        \"command\": \"make test\"
      }
    ]
  }
  • 在您的第一个 json 文件中,您有 C/C++: g++.exe build active file,而在您的第二个文件中,您有 C/C++: gcc.exe build active file
  • 您是在尝试编译 c 还是 c++?请不要同时标记两者。如果 c++ 你需要使用 g++ 而不是 gcc
  • 您可以将launch.json preLaunchTask 和tasks.json label 设置为更易于阅读或检查的内容,例如build-appbuild-debug

标签: c visual-studio-code gcc gdb


【解决方案1】:

"preLaunchTask": "C/C++: g++.exe build active file" 在launch.json,应该和"label": "C/C++: gcc.exe build active file" 在tasks.json 一致。

【讨论】:

    猜你喜欢
    • 2021-02-07
    • 2020-07-26
    • 2020-03-25
    • 1970-01-01
    • 2018-05-23
    • 2020-06-12
    • 2019-02-23
    • 1970-01-01
    • 2021-04-21
    相关资源
    最近更新 更多