安装vscode 插件
下载mingw64
https://sourceforge.net/projects/mingw-w64/files/
选择x86_64-posix-seh
在代码目录新建三个json配置文件
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"D:/ProgramFiles/mingw64/**"
// "D:/ProgramFiles/mingw64/include",
// "D:/ProgramFiles/mingw64/x86_64-w64-mingw32/include",
// "D:/ProgramFiles/mingw64/lib/gcc/x86_64-w64-mingw32/5.1.0/include",
// "D:/ProgramFiles/mingw64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
launch.json
{
"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": "${workspaceFolder}",
"environment": [],
"externalConsole": true, //修改此项,让其弹出终端
"MIMode": "gdb",
"miDebuggerPath": "D:\\ProgramFiles\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "task g++" //修改此项
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "task g++", //修改此项
"command": "D:\\ProgramFiles\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "D:\\ProgramFiles\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
运行调试
按F5 快捷键 调试运行