关于解决:VSC无法将make项识别为cmdlet、函数、脚本文件或可运行程序的名称

之前提问过关于MinGW配置好后,VSC出现如下报错的问题:
关于解决:VSC无法将make项识别为cmdlet、函数、脚本文件或可运行程序的名称_第1张图片
后面我重新查了一些资料,看了一些文章,从配置环境的四个文件出发做了修改解决了这个问题,具体代码如下:
c_cpp_properties.json

{
  "configurations": [
    {
      "name": "windows-gcc-x64",
      "intelliSenseMode": "windows-gcc-x64",
      "compilerPath": "D:\\mingw64GCC\\mingw64\\bin\\gcc.exe",
      "includePath": [
        "${workspaceFolder}/**",
        "${workspaceFolder}"
      ],
      "cppStandard": "c++17",
      "compilerArgs": [],
      "cStandard": "c11"
    }
  ],
  "version": 4
}

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "(gdb) Launch",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": true,
      "MIMode": "gdb",
      "miDebuggerPath": "D:\\mingw64GCC\\mingw64\\bin\\gdb.exe",
      "preLaunchTask": "g++",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ]
    },
    {
      "name": "C/C++ Runner: Debug Session",
      "type": "cppdbg",
      "request": "launch",
      "args": [],
      "stopAtEntry": false,
      "cwd": "d:\\1VS Projcct_cpp",
      "environment": [],
      "program": "d:\\1VS Projcct_cpp\\build\\Debug\\outDebug",
      "internalConsoleOptions": "openOnSessionStart",
      "MIMode": "gdb",
      "miDebuggerPath": "D:\\mingw64GCC\\mingw64\\bin\\gdb.exe",
      "externalConsole": false
    }
  ]
}

settings.json

{
  "C_Cpp_Runner.warnings": [],
  "C_Cpp_Runner.compilerArgs": [],
  "C_Cpp_Runner.includePaths": [
    "${workspaceFolder}"
  ],
  "C_Cpp_Runner.linkerArgs": [],
  "C_Cpp_Runner.cppStandard": "c++17",
  "C_Cpp_Runner.excludeSearch": [],
  "C_Cpp_Runner.enableWarnings": true,
  "C_Cpp_Runner.warningsAsError": false,
  "C_Cpp_Runner.debuggerPath": "D:\\mingw64GCC\\mingw64\\bin\\gdb.exe",
  "C_Cpp_Runner.cCompilerPath": "D:\\mingw64GCC\\mingw64\\bin\\gcc.exe",
  "C_Cpp.default.compilerPath": "c:/Users/Zurich Yang/.vscode/extensions/bartmanabyss.amiga-debug-1.0.0/bin/opt/bin/m68k-amiga-elf-gcc.exe",
  "C_Cpp_Runner.cppCompilerPath": "D:\\mingw64GCC\\mingw64\\bin\\g++.exe",
  "C_Cpp_Runner.makePath": "D:\\mingw64GCC\\mingw64\\bin\\make.exe",
  "C_Cpp_Runner.cStandard": "c11"
}

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "g++", //这里注意一下,见下文
            "command": "D:\\mingw64GCC\\mingw64\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "-ggdb3",   // 生成和调试有关的信息
                "-Wall",    // 开启额外警告
                "-static-libgcc",   // 静态链接
                "-std=c++17",       // 使用c++17标准
                "-finput-charset=UTF-8",    //输入编译器文本编码 默认为UTF-8
                "-fexec-charset=GB18030",   //输出exe文件的编码
                "-D _USE_MATH_DEFINES"
            ],
            "options": {
                "cwd": "D:\\mingw64GCC\\mingw64\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "presentation": {
                "echo": true,
                "reveal": "always", // 在“终端”中显示编译信息的策略,可以为always,silent,never
                 "focus": false,
                 "panel": "shared" // 不同的文件的编译信息共享一个终端面板
            },
        }
    ]
}


最后如果还有任何问题推荐去看一下这位up主的经验视频,连接如下:
【【小神仙讲 vscode教程】 十五分钟快速 win vscode C++ 环境搭建-哔哩哔哩】https://b23.tv/fVrqQr

你可能感兴趣的:(C++,VSC,编译环境,c++)