【问题标题】:VsCode while running c++ program运行 C++ 程序时的 VsCode
【发布时间】:2018-08-13 06:03:27
【问题描述】:

这是我的 VsCode 的 launch.json 文件:

{
"version": "0.2.0",
"configurations": [
    {
        "name": "C++ Launch (GDB)",                
        "type": "cppdbg",                         
        "request": "launch",                        
        "targetArchitecture": "x86",                
        "program": "${workspaceRoot}\\${fileBasename}.exe",                 
        "miDebuggerPath":"C:\\mingw-w64\\bin\\gdb.exe", 
        "args": [],     
        "stopAtEntry": false,                  
        "cwd": "${workspaceRoot}",                  
        "externalConsole": true,                  
        "preLaunchTask": "g++"                    
        }
]

} 如果我的 tasks.json 文件是这个:

{
"version": "2.0.0",
"tasks": [
    {
        "label": "<TASK_NAME>",
        "type": "shell",
        "command": "make",
        // use options.cwd property if the Makefile is not in the project root ${workspaceRoot} dir
        "options": {
            "cwd": "${workspaceRoot}/<DIR_WITH_MAKEFILE>"
        },
        // start the build without prompting for task selection, use "group": "build" otherwise
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "presentation": {
            "echo": true,
            "reveal": "always",
            "focus": false,
            "panel": "shared"
        },
        // arg passing example: in this case is executed make QUIET=0
        "args": ["QUIET=0"],
        // Use the standard less compilation problem matcher.
        "problemMatcher": {
            "owner": "cpp",
            "fileLocation": ["absolute"],
            "pattern": {
                "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                "file": 1,
                "line": 2,
                "column": 3,
                "severity": 4,
                "message": 5
            }
        }
    }
]}

他们以前和今天都没有工作过。当我运行任务终端时显示: 它也在建设: 然后当我调试(F5)程序时,它会显示:

请帮助我如何运行 c++ 程序。感谢您的回答!

【问题讨论】:

    标签: c++ visual-studio-code


    【解决方案1】:

    您已经配置了一个名为 g++ 的预启动任务,但没有该名称的任务。您需要将构建任务的名称更改为 g++。

    您只需更改label 的值以匹配tasks.json 中的任务名称

    【讨论】:

      猜你喜欢
      • 2020-12-12
      • 1970-01-01
      • 1970-01-01
      • 2021-05-03
      • 1970-01-01
      • 2020-02-04
      • 2021-12-04
      • 1970-01-01
      • 2020-07-11
      相关资源
      最近更新 更多