vscode配置cpp调试环境
安装vscode插件
1. c/c++
2. cmake
3. cmake-tool
安装程序
1 |
|
配置vscode
- c_cpp_properties.json
菜单栏【查看】【命令面板…】
输入关键词”C/C++ edit”,选择匹配到的命令”C/C++: Edit Configurations (json)”
1 |
|
添加task.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
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
55
56
57
58
59
60{
"version": "2.0.0",
"options": {
"cwd": "${workspaceFolder}" //需要进入到我们执行tasks任务的文件夹中
},
"tasks": [
{
"type": "shell",
"label": "mkdir",
"group": {
"kind": "build",
"isDefault": true
},
"command": "mkdir",
"args": [
"-p",
"build"
]
},
{
"type": "shell",
"label": "cmake",
"group": {
"kind": "build",
"isDefault": true
},
"options": {
"cwd": "${workspaceFolder}/build"
},
"command": "cmake",
"args": [
".."
]
},
{
"label": "make",
"group": {
"kind": "build",
"isDefault": true
},
"options": {
"cwd": "${workspaceFolder}/build"
},
"command": "make",
"args": [
"-j4"
]
},
{
"label": "build",
"dependsOrder": "sequence",
"dependsOn": [
"mkdir",
"cmake",
"make"
]
}
]
}这里实际上将手动的make过程程序化,有需要可以对task任务加减,如:添加rm -rf CMakeCache.txt命令
添加launch.json
实际的调试入口,启动task任务
1 |
|
执行
写好CMakeLists.txt
ctrl+shift+D 点击launch任务
done
vscode配置cpp调试环境
http://example.com/2020/04/12/vscode配置cpp调试环境/