赞
踩
去vscode官网,通过官网选择合适的操作系统进行下载安装
在nodejs官网,通过官网,下载安装对应的nodejs
通过文档MinGW下载与安装,进行MinGW的下载与配置
根据文档VS Code运行C和C++程序,配置C++环境
创建本地文件夹并打开,并新增一个.cpp结尾的文件
添加C++编辑的配置,配置编译器的路径以及IntelliSense模式
然后下图指示添加配置,然后依次选择C++(GDB),g++
然后校验一下本地是否已经生成了的如下的文件:
第二步生成的c_cpp_properties.json以及第三步生成的launch.json以及tasks.json
// c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:/msys64/mingw64/bin/g++.exe", //校验g++路径是否与本地安装路径一致
"cStandard": "c17",
"cppStandard": "c++17", // 支持c++17
"intelliSenseMode": "gcc-x64" // 上面强调的与g++对应的intelliSense模式
}
],
"version": 4
}
// launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "C:/msys64/mingw64/bin",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe", // 校验gdb路径是否正确
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe 生成活动文件"
}
]
}
// tasks.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe 生成活动文件",
"command": "C:/msys64/mingw64/bin/g++.exe", // 校验g++路径是否正确
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-std=c++17" // 配置支持c++17
],
"options": {
"cwd": "C:/msys64/mingw64/bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
【1】VS Code运行C和C++程序
【2】vscode调试C++
【3】MinGW下载与安装
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。