在windows上安裝gcc環境
到官網下載mingw安裝包。官網地址
安裝詳情參考c++
爲了在cmd中使用gcc命令,應該將程序的地址添加到環境變量中。
而後在cmd中輸入gcc -v命令查看是否安裝成功。
json
安裝c/c++插件
在主界面按shift+ctrl+x進入搜索界面,輸入c/c++,而後安裝圖中第一個。
windows
添加一些配置信息
在工做文件夾中建立一個.vscode文件夾。
配置兩個文件,一個是launch.json另外一個是tasks.json。
launch.jsonui
{ "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.jsonspa
{ "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 } }