如何解决“找不到任务'gcc构建活动文件”。 VSCode中的错误? [英] How to solve "Could not find the task 'gcc build active file." error in VSCode?

查看:757
本文介绍了如何解决“找不到任务'gcc构建活动文件”。 VSCode中的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将 VSCode 设置为可以与运行 Gentoo x64 的远程 SSH 在家工作。除了通常使用的 GCC 调试器之外,其他所有工具都可以正常工作。

I've just setup VSCode to work from home with my remote SSH that runs Gentoo x64. Everything works fine apart from the GCC debugger which we usually use. It throws me the error in the title.

这是我的 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 标志。有关如何解决此问题的任何想法?

And yes, I do compile with the -g flag. Any ideas on how to fix this?

推荐答案

您将需要添加gdb配置:

You will need to add gdb configuration:

在调试菜单的左侧,单击调试图标,在顶部的下拉菜单中有默认配置 gcc构建活动文件 ,您需要单击该并选择添加配置 ,选择(gdb)启动,将添加到 launch.json 类似于:

In the debug menu, left side, click the debug icon, in the top you have a drop down menu where you have you default config "gcc build active file", you will need to click that and select "add configuration", select (gdb) Launch, this will add to the launch.json something along the lines of:

    "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
                }
            ]
        }
    ]

当然,我的窗户是窗户,所以您的窗户会有所不同。

Of course mine is windows so yours will be different.

您可能必须配置可执行文件的名称,工作文件夹,gdb位置等。

You might have to configure the name of the executable, working folder, gdb location, etc.

然后在同一下拉菜单中选择(gdb)启动

Then in the same dropdown menu select (gdb) Launch

这篇关于如何解决“找不到任务'gcc构建活动文件”。 VSCode中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆