-
在windows上安装gcc环境
到官网下载mingw安装包. -
添加一些配置信息
在工作文件夹中创建一个.vscode文件夹。
配置两个文件,一个是launch.json另一个是tasks.json。
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++", "type": "cppdbg", "request": "launch", "program": "${fileDirname}/build/${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb", "miDebuggerPath": "E:/vscoodeWorkplace/mingw64/bin/gdb.exe", "preLaunchTask": "g++", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], }, ] }
tasks.json
{
"version": "2.0.0",
"command": "g++",
"args": [ "-g", "${file}", "-o", "${fileDirname}/build/${fileBasenameNoExtension}.exe" ], "problemMatcher": { "owner": "cpp", "fileLocation": [ "relative", "${workspaceRoot}" ], "pattern": { "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 } }, "group": { "kind": "build", "isDefault": true } }