VScode给出输出的终端:'g ++'不被识别为内部或外部命令,可操作程序或批处理文件

问题描述 投票:0回答:1

我首先从https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/安装Mingw,然后下载了所有软件包,并将C:\ MinGW \ bin设置为我的环境系统变量中的新路径。我打开命令提示符,然后键入“ g ++ --version”,这会给我输出“ g ++(MinGW.org GCC-8.2.0-5)8.2.0”。因此,我相信这意味着到目前为止,我已经遵循了正确的路径。

我在VSCode中尝试编译基本的hello world文件时出现问题。在终端中,我输入“ g ++ main.cpp”,但是这使我无法将输出“ g ++”识别为内部或外部命令,可操作的程序或批处理文件。”这与我的.json文件的设置方式有关吗?我包括以下c_cpp_poperties,启动和任务代码。

谢谢。

c_cpp_properties.json:

{
"configurations": [
    {
        "name": "Win32",
        "includePath": [
            "${workspaceFolder}/**"
        ],
        "defines": [
            "_DEBUG",
            "UNICODE",
            "_UNICODE"
        ],
        "compilerPath": "C:\\MinGW\\bin\\gcc.exe",
        "cStandard": "c11",
        "cppStandard": "c++17",
        "intelliSenseMode": "gcc-x64"
    }
],
"version": 4}

launch.json:

{
"version": "0.2.0",
"configurations": [
    {
        "name": "C++ Compiler",
        "type": "cppvsdbg",
        "request": "launch",
        "program": "C:/MinGW/bin",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": true
    },
]}

task.json:

{
"version": "2.0.0",
"tasks": [
  {
    "label": "build hello world",
    "type": "shell",
    "command": "C:/MinGW/bin/g++",
    "args": [
      "-g",
      "-o",
      "helloworld",
      "helloworld.cpp"
    ],
    "group": {
      "kind": "build",
      "isDefault": true
    }
  }
]}
c++ visual-studio-code g++ mingw
1个回答
0
投票

替换

    "compilerPath": "C:\\MinGW\\bin\\gcc.exe",

使用

    "compilerPath": "C:\\MinGW\\bin\\g++.exe",
© www.soinside.com 2019 - 2024. All rights reserved.