1. 下载
VSCode下载
https://code.visualstudio.com/
插件:CMake、C/C++、Chinese(Simplified)
MinGW下载
https://zhuanlan.zhihu.com/p/76613134
https://sourceforge.net/projects/mingw-w64/
百度网盘: http://pan.baidu.com/s/1crx1s
CMake下载
2. vscode配置
- 在顶层目录下,新建.vscode文件夹
- 在.vscode目录下,新建launch.json文件,内如如下
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"preLaunchTask": "build",
"type": "cdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "E:/path/MinGW/bin/gdb.exe", // 这里修改GDB路径为安装的mingw64的bin下的gdb.exe路径
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true,
}
]
}]
}
- 在.vscode目录下,新建tasks.json文件,内如如下
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"windows": {
"command": "gcc",
"args": [
"-ggdb",
"\"${file}\"",
"--std=c99",
"-o",
"\"${fileDirname}\\${fileBasenameNoExtension}.exe\"",
// "-finput-charset=UTF-8",// 输入编译器文本编码 默认为UTF-8
// "-fexec-charset=GBK"// 编译器输出文本编码 自行选择
]
}
}
]
}
- F5调试运行