- 安装
MinGW 64 - VSCode安装
C/C++ 扩展 - VSCode配置编译器:按快捷键 Ctrl+Shift+P 调出命令面板,输入
C/C++ ,选择“Edit Configurations(UI) ”进入配置(配置后生成 .vscode 文件夹,包含 c_cpp_properties.json 文件):
- 编译器路径:
D:/mingw64/bin/g++.exe (MinGW 64 安装路径) - IntelliSense 模式:
gcc-x64 - VSCode配置构建任务:按快捷键 Ctrl+Shift+P 调出命令面板,输入
tasks ,选择“Tasks:Configure Default Build Task ”进入配置,选择“C/C++: g++.exe build active file ”(创建一个 tasks.json 文件) - VSCode配置调试设置:点击菜单栏的
Run-->Start Debugging ,选择“C++(GDB/LLDB) ”(创建一个 launch.json 的文件) 修改 launch.json 文件内容:
"preLaunchTask": "g++.exe build active file" , // 调试前执行的任务,修改为之前配置的tasks.json中的label字段"miDebuggerPath": "D:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe" , // 修改为 MinGW 64 安装路径
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"preLaunchTask": "g++.exe build active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
|