1 安装MinGW-w64
MinGW-w64 - for 32 and 64 bit Windows
选择 “x86_64-posix-seh” ,会自动下载一个 7z的压缩包。 下载之后, 解压到本地, 如 D:\mingw64. 然后将 D:\mingw64\bin 加入系统环境变量, 加好后在命令行里输入gcc -v 查看是否成功。
2 配置 Visual Studio Code
2.1 安装扩展
安装好vs code, 需要安装一些c++用的扩展并进行一些配置。
在扩展里搜索并安装:
C/C++
C/C++ Snippets
Code Runner
Include Autocomplete
2.2 配置调试和任务
点击调试-》添加配置 -》 选 C++(GDB/LLDB), 会自动新建一个 launch.json, 将它改成以下的内容:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole"