【问题标题】:How to solve "Could not find the task 'gcc build active file." error in VSCode?如何解决“找不到任务'gcc build active file”。 VSCode 中的错误?
【发布时间】:2020-07-26 06:24:49
【问题描述】:

我刚刚将 VSCode 设置为使用运行 Gentoo x64 的远程 SSH 在家工作。除了我们通常使用的 GCC 调试器之外,一切正常。它在标题中引发了我的错误。

这是我的launch.json

{
"version": "0.2.0",
"configurations": [
    {
        "name": "gcc - Build and debug active file",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}/${fileBasenameNoExtension}",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "preLaunchTask": "gcc build active file",
        "miDebuggerPath": "/usr/bin/gdb"
    }
]
}

还有我的tasks.json

{
"version": "2.0.0",
"tasks": [
    {
        "type": "shell",
        "label": "C/C++: gcc build active file",
        "command": "/usr/bin/gcc",
        "args": [
            "-g",
            "${file}",
            "-o",
            "${fileDirname}/${fileBasenameNoExtension}"
        ],
        "options": {
            "cwd": "/usr/bin"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": "build"
    }
]
}

是的,我确实使用-g 标志进行编译。有关如何解决此问题的任何想法?

【问题讨论】:

    标签: c linux debugging gcc visual-studio-code


    【解决方案1】:

    您需要添加 gdb 配置:

    在左侧的调试菜单中,单击调试图标,在顶部有一个下拉菜单,其中有默认配置"gcc build active file",您需要单击它并选择"add configuration",然后选择@987654323 @,这将添加到 launch.json 中,类似于:

        "version": "0.2.0",
        "configurations": [
            {
                "name": "(gdb) Launch",
                "type": "cppdbg",
                "request": "launch",
                "program": "${workspaceFolder}/a.exe",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${workspaceFolder}",
                "environment": [],
                "externalConsole": false,
                "MIMode": "gdb",
                "miDebuggerPath": "C:\\TDM-GCC-64\\bin\\gdb.exe",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        ]
    

    当然我的是窗户,所以你的会不一样。

    您可能需要配置可执行文件的名称、工作文件夹、gdb 位置等。

    然后在同一个下拉菜单中选择(gdb) Launch

    【讨论】:

      猜你喜欢
      • 2020-03-25
      • 2023-03-23
      • 2022-08-18
      • 1970-01-01
      • 1970-01-01
      • 2018-01-31
      • 2019-11-28
      • 2014-09-24
      • 2012-03-02
      相关资源
      最近更新 更多