繁体   English   中英

如何解决“找不到任务'gcc build active file”。 VSCode 中的错误?

[英]How to solve “Could not find the task 'gcc build active file.” error in VSCode?

我刚刚使用运行Gentoo x64的远程SSHVSCode设置为在家工作。 除了我们通常使用的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标志进行编译。 有想法该怎么解决这个吗?

您将需要添加 gdb 配置:

在左侧的调试菜单中,单击调试图标,在顶部您有一个下拉菜单,其中您有默认配置"gcc build active file" ,您需要单击它并 select "add configuration" ,select (gdb) Launch ,这将添加到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
                }
            ]
        }
    ]

当然我的是 windows 所以你的会有所不同。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM