vscode配置C++编译环境MinGW64步骤
ctrl + shift + P 进行配置搜索
>C/C++:Edit Configurations(UI)
配置名称下面线添加配置,名称可以命名为Win64,这样可以在右下角快速选择配置好的编译环境
1.IntelliSense配置下编译器路径填写MinGW64文件下g++.exe路径
C:\MinGW64\mingw64\bin\g++.exe
2.IntelliSense模式下拉框选择 gcc-x64(legacy)
结果:.vscode下出现c_cpp_properties.json文件
>Tasks:Configure Default Build Task
出现C/C++: g++.exe 生成活动文件就选择编辑,否则进行默认创建
{
//tasks.json具体内容
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "cppbuild",
"command": "C://MinGW64//mingw64//bin//g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd":"C://MinGW64//mingw64//bin//",
},
"problemMatcher": [
"s$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "编译器: C://MinGW64//mingw64//bin//g++.exe"
}
]
}
首页菜单栏中 运行->添加配置
C++(GDB/LLDB)
编辑生成的launch.json文件
{
//右下角添加配置 C/C++: (gdb) 启动 之后可以生成以下代码
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "输入程序名称,例如 ${workspaceFolder}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/path/to/gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
欧克(配置好之后最好重启一下vscode)