【问题标题】:The preLaunchTask 'helloworld' terminated with exit code 1preLaunchTask 'helloworld' 以退出代码 1 终止
【发布时间】:2018-07-25 07:48:59
【问题描述】:

当我编译我的 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
 }

【问题讨论】:

  • 不知道为什么这被标记为 c 但是\,我猜你需要使用 g++ 的完整路径,因为它可能是运行环境的 PATH 的一部分

标签: c json windows visual-studio-code


【解决方案1】:

我已将 mingw-64 文件从“C:\Program Files (x86)”移动到“桌面”,并且在 tasks.json 中指定了完整路径(即,(“command”: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",) 这是目标的工作目录

【讨论】:

    猜你喜欢
    • 2017-04-25
    • 2022-12-15
    • 2021-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-28
    • 1970-01-01
    相关资源
    最近更新 更多