vscode下搭建C/C++环境
mingw64安装
可以到官网下载mingw-w64-install.exe用来引导安装,也可以直接下载压缩包。按照提示安装即可。
插件安装
C/C++
Code Runner
launch.json文件配置
{ "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "preLaunchTask": "build", "type": "cppdbg", "request": "launch", "program": "${fileDirname}/${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb", "miDebuggerPath": "C:\\mingw64\\bin\\gdb.exe", // GDB的路径,注意替换成自己的路径 "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] }] }
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": "g++", "args": [ "-ggdb", "\"${file}\"", "--std=c++11", "-o", "\"${fileDirname}\\${fileBasenameNoExtension}.exe\"" ] } } ] }
参考
来源:https://www.cnblogs.com/wheszza/p/12244761.html