win10环境下VS Code的C++环境配置
Acid
  • 待修改
    Dev-C++不好看
    VS太大
    VSC真香

下载并安装VSC

  • 官网下载对应的版本即可
  • 安装时这些全选
    image-20210115174528823
  • 安装插件cpptools
  • 其他有必要的插件也可以安装 如主题美化、图标美化、汉化等等

下载并安装MinGW

  • 打开下载网址
  • 向下翻找到这个下载
    image-20210115174000244
  • 解压mingw64文件夹到一个目录 这里我选择C:\Program Files

添加环境变量

  • 复制mingw64文件夹中bin文件夹的路径C:\Program Files\mingw64\bin
  • 按照图示配置环境变量
    image-20210115175314817
  • 测试是否配置成功 打开cmd 输入gdb -v 若显示版本则为成功
    image-20210115175607492

配置环境

  • 创建一个专门写C++代码的文件夹 在VSC中打开并新建一个cpp文件
    image-20210115180139136
  • 打开调试界面
    image-20210115180343887
    image-20210115180807617
  • 会自动生成launch.jsontasks.json 按照下边修改
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "C:\\Program Files\\mingw64\\bin",
"environment": [],
"externalConsole": true, // 修改此项为true
"MIMode": "gdb",
"miDebuggerPath": "C:\\Program Files\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\Program Files\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\Program Files\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Task generated by Debugger."
},
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file ver(1)",
"command": "C:\\Program Files\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\Program Files\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger.",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "new",
"showReuseMessage": true,
"clear": false
}
}
],
"version": "2.0.0"
}
  • 之后就可以愉快的写代码了 按F5进行调试
    image-20210115182505359
  • 本文标题:win10环境下VS Code的C++环境配置
  • 本文作者:Acid
  • 创建时间:2021-01-15 16:04:42
  • 本文链接:https://blog.acidwits.xyz/2021/01/15/0012/
  • 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
 评论