首页 > 解决方案 > vscode 构建,创建 exe 文件,突然不再启动(C++)

问题描述

每当我按下 F5 时,VSCode 一直使用 raylib 和 C++ 从 main 构建、创建和运行 .exe 文件。然而,它突然停止了,我不知道为什么。

完成构建和创建 .exe 终端后,它只会说:“终端将被任务重用,按任意键关闭它”。

.exe 文件被创建并放在文件夹中。按 F5 时,如何让它返回构建、创建和运行 .exe?

任务.json

{

            "type": "cppbuild",
            "label": "C/C++: gcc.exe build active file",
            "command": "C:/raylib/mingw/bin/gcc.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:/raylib/mingw/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: C:/raylib/mingw/bin/gcc.exe"
}

启动.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": "Debug",
          "type": "cppdbg",
          "request": "launch",
          "program": "${workspaceFolder}/${fileBasenameNoExtension}",
          "args": [],
          "stopAtEntry": false,
          "cwd": "${workspaceFolder}",
          "environment": [],
          "externalConsole": false,
          "MIMode": "gdb",
          "setupCommands": [
            {
              "description": "Enable pretty-printing for gdb",
              "text": "-enable-pretty-printing",
              "ignoreFailures": false
            }
          ],
          "windows": {
            "miDebuggerPath": "C:/raylib/mingw/bin/gdb.exe",
          },
          "osx": {
            "MIMode": "lldb"
          },
          "linux": {
            "miDebuggerPath": "/usr/bin/gdb",
          },
          "preLaunchTask": "build debug"
        },
        {
          "name": "Run",
          "type": "cppdbg",
          "request": "launch",
          "args": [],
          "stopAtEntry": false,
          "cwd": "${workspaceFolder}",
          "environment": [],
          "externalConsole": false,
          "program": "${workspaceFolder}/${fileBasenameNoExtension}",
          "MIMode": "gdb",
          "windows": {
            "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
            "miDebuggerPath": "C:/raylib/mingw/bin/gdb.exe"
          },
          "osx": {
            "MIMode": "lldb"
          },
          "linux": {
            "miDebuggerPath": "/usr/bin/gdb"
          },
          "preLaunchTask": "build release",
        }
      ]
    }

gdb.exe 是它应该在的地方: 在此处输入图像描述

这个问题甚至发生在一个小时前还在工作的示例模板上: https ://github.com/raysan5/raylib/tree/master/projects/VSCode/.vscode

标签: c++visual-studio-codeterminalexelaunch

解决方案


问题出在 Microsoft C/C++ 扩展上。在切换到“默认”后,我猜它基本上会从稳定版本降级,一切都恢复正常了。

它被自动设置为“内部人员”频道,我不知道为什么,但 1.6 版没有正确启动调试器或 exe(这东西让我头疼)。如果东西坏了,微软强迫“内部人员”频道可能不好。

在此处输入图像描述


推荐阅读