参考配置步骤
build.sh:
#!/usr/bin/env bash
rm -rf build/
echo "创建编译目录:build"
mkdir build
echo "in编译目录:build"
cd build/
echo "do:cmake"
cmake ../
echo "do:make"
make
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "run udp1", //名称随便取
"type": "cppdbg", //调试类型
"request": "launch", //请求配置类型
"program": "${workspaceFolder}/build/udp_server", //可执行程序完整路径(包含程序名称)
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build", //可执行程序完整路径(不包含程序名称)
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "run udp", //task 任务名称(与tasks.json中名称一致)
"miDebuggerPath": "/usr/bin/gdb" //gdb完整路径
}
]
}
task.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "run udp",
"command": "./build.sh",
"problemMatcher": []
}
]
}