【问题标题】:Error: "The preLaunchTask 'C/C++: g++.exe build active file' terminated with exit code 1"错误:“preLaunchTask 'C/C++: g++.exe build active file' 以退出代码 1 终止”
【发布时间】:2021-02-07 16:00:23
【问题描述】:

我了解到此错误是由于 launch.json 和 tasks.json 文件中的某些设置造成的。所以我删除了它们并制作了新的,但它给出了相同的错误并且不会构建和调试。我该如何解决?

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": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}

Tasks.json:

{
    "tasks": [
        {
            "type": "shell",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ],
    "version": "2.0.0"
}

【问题讨论】:

    标签: c++ json visual-studio-code compiler-errors


    【解决方案1】:

    如果您之前编译过代码并且已经创建了可执行 (*.exe) 文件,请通过 VS 代码文件资源管理器将其删除,然后再次尝试构建您的代码。 这就是问题所在,至少在我的情况下。 VS 代码无法删除可执行文件以创建新的。

    【讨论】:

      猜你喜欢
      • 2022-12-15
      • 2017-04-25
      • 2018-07-25
      • 2022-08-18
      • 2020-09-28
      • 1970-01-01
      • 1970-01-01
      • 2022-12-12
      • 1970-01-01
      相关资源
      最近更新 更多