preLaunchTask'helloworld'以退出代码1终止

时间:2018-02-14 16:47:59

标签: c json windows visual-studio-code

当我正在编译我的c文件时,我收到了错误

(/“”执行任务:g ++ -g helloworld.c<

'g ++'未被识别为内部或外部命令, 可操作程序或批处理文件。 终端进程以退出代码终止:1

终端将被任务重用,按任意键关闭它。“”/)

我的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": "(gdb) Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": " C:/wamp/www/ShareIdea/helloworld.c/hello.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb",
        "miDebuggerPath": "C:\\Program Files (x86)\\mingw-w64\\i686-7.2.0-posix-dwarf-rt_v5-rev1\\mingw32\bin\\gdb.exe",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "preLaunchTask": "helloworld"
    }



]
}

我的“tasks.json”文件是

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
    {
        "label": "helloworld",
        "type": "shell",
        "command": "g++",
        "args": [
            "-g",
            "helloworld.c"
        ]
        }

]
}

我已将c_cpp_properties.json编辑为

       {
  "configurations": [
      {
        "name": "Win32",
        "includePath": [
            "${workspaceFolder}",
            "C:/Program Files (x86)/mingw-w64/i686-7.2.0-win32-dwarf-rt_v5-rev1/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/tr1",
            "C:/Program Files (x86)/mingw-w64/i686-7.2.0-win32-dwarf-rt_v5-rev1/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++",
            "C:/Program Files (x86)/mingw-w64/i686-7.2.0-win32-dwarf-rt_v5-rev1/mingw32/i686-w64-mingw32/include"
        ],
        "defines": [
            "_DEBUG",
            "UNICODE"
        ],
        "intelliSenseMode": "msvc-x64",
        "browse": {
            "path": [
                "${workspaceRoot}",
                "C:\\Program Files (x86)\\mingw-w64\\i686-7.2.0-win32-dwarf-rt_v5-rev1\\mingw32\\lib\\gcc\\i686-w64-mingw32\\7.2.0\\include\\c++",
                "C:\\Program Files (x86)\\mingw-w64\\i686-7.2.0-win32-dwarf-rt_v5-rev1\\mingw32\\lib\\gcc\\i686-w64-mingw32\\7.2.0\\include\\ssp\\stdio",
                "C:\\Program Files (x86)\\mingw-w64\\i686-7.2.0-win32-dwarf-rt_v5-rev1\\mingw32\\i686-w64-mingw32\\include"
            ],
            "limitSymbolsToIncludedHeaders": true,
            "databaseFilename": ""
        }
    }
],
"version": 3
 }

1 个答案:

答案 0 :(得分:1)

我已将mingw-64文件从“C:\ Program Files(x86)”移动到“桌面”,并且我在tasks.json中指定了完整路径(即,“”命令“:C:\ Users \ varunteja \ Desktop \ mingw-w64 \ i686-7.2.0-win32-dwarf-rt_v5-rev1 \ mingw32 \ bin \ g ++“,)而不是(”command“:”g ++“,))。

我还编辑了“Launch.json”文件。 在Launch.json文件中,我编辑了(“program”:“C:/wamp/www/ShareIdea/helloworld.c/hello.exe”),作为(“program”:“C:/ wamp / www / ShareIdea / a .exe“,)我开始调试时创建了a.exe文件。

我也改变了cwd(“cwd”:“C:/ wamp / www / ShareIdea”),这是目标的工作目录