Windows平台下配置VS Code的C++环境教程

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Windows平台下配置VS Code的C++环境教程

后厂村路蔡徐坤   2022-12-15 我要评论

一、下载VS Code

下载链接:https://code.visualstudio.com/Download

二、下载CPP插件

三、安装编译器和调试器

下载地址:https://sourceforge.net/projects/mingw-w64/files/

下载的文件:进入网站后不要点击 “Download Lasted Version”,往下滑,找到最新版的 “x86_64-posix-seh”。

四、设置系统环境变量

验证:

按下 win + R,输入cmd,回车键之后输入g++,再回车,如果提示以下信息[1],则环境变量配置成功。

如果提示以下信息[2],则环境变量配置失败。

[1]:g++: fatal error: no input files

[2]:'g++' 不是内部或外部命令,也不是可运行的程序或批处理文件。

五、修改VScode调试、编译配置文件

文件夹中.vscode文件主要用于防止调试器和编译器配置文件

{
    "version": "0.2.0",
    "configurations": [
      {
        "name": "g++.exe - Build and debug active file",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${fileDirname}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb",
        "miDebuggerPath": "D:\\mingw64\\bin\\gdb.exe",
        "setupCommands": [
          {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
          }
        ],
        "preLaunchTask": "C/C++: g++.exe build active file"
      }
    ]
  }

{
    "tasks": [
      {
        "type": "cppbuild",
        "label": "C/C++: g++.exe build active file",
        "command": "D:\\mingw64\\bin\\g++.exe",
        "args": ["-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe"],
        "options": {
          "cwd": "${fileDirname}"
        },
        "problemMatcher": ["$gcc"],
        "group": {
          "kind": "build",
          "isDefault": true
        },
        "detail": "compiler: D:\\mingw64\\bin\\g++.exe"
      }
    ],
    "version": "2.0.0"
  }

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持。

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们