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

标签 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
 }

最佳答案

我已将 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 文件中,我编辑了(“程序”:“C:/wamp/www/ShareIdea/helloworld.c/hello.exe”,)作为(“程序”:“C:/wamp/www/ShareIdea/a .exe",) 当我开始调试时创建了一个.exe文件。

我也将 cwd 更改为 ("cwd": "C:/wamp/www/ShareIdea",) 这是目标的工作目录

关于c - preLaunchTask 'helloworld' 以退出代码 1 终止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48792261/

相关文章:

python - 在 Python SWIG 中包装 void * 参数

javascript - 从 symfony Controller 返回 json 数组,以便在 highcharts.js 上使用

javascript - 非常基本的 jquery + ajax

c++ - 如何使用 IFileOperation 清空文件夹

c - 如何将暂停的进程设置为后台?

c - 如何在不使用 strlen 的情况下找到 C 字符串的长度?

ios - Firebase 检索数据 - 无法转换值(value)

windows - 如何使用 Delphi 检查字符串是否是有效的 Windows 文件夹名称?

c++ - 无法在 Windows XP 上编译 rsa.h

C 函数语法