task.json:
{
"version": "2.0.0",
"options": {
"cwd": "${workspaceRoot}/build"
},/////////////////////////////////////////////////设置编译启动时路径,将makefile保存到build路径
"tasks": [
{
"label": "cmake",
"type": "shell",
"command": "cmake",
"args": [
"-G",
"MinGW Makefiles",
".."
],
},
{
"label": "make",/////////////////////// make
"type": "shell",
"command": "mingw32-make",
"args": [],
"group": {
"kind": "build",
"isDefault": true
},
"dependsOn":["cmake"],
},
]
}
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/hello1", //指定要调试的文件路径
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "make" //////////////////////// 调试前先启动make
}
]
}
