基础环境配置
mac环境下,自带的是clang,在编辑haproxy的时候会出现一系列的warning,所以先安装下gcc,haproxy官方测试通过的只有4.x版本
brew install [email protected]
然后修改haproxy的Makefile,120行。
CC = /usr/local/Cellar/gcc\@4.9/4.9.4_1/bin/gcc-4.9
编译安装
make TARGET=osx
make install PREFIX=/opt/haproxy
vscode 配置
- tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "haproxy",
"type": "shell",
"command": "sudo make TARGET=osx && sudo make install PREFIX=/opt/haproxy && sudo make clean",
"problemMatcher": [
"$gcc"
]
}
]
}
此时运行任务的时候就自动执行tasks.json的任务,进行编译,完成之后就能顺利调试。
- launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "/opt/haproxy/sbin/haproxy",
"args": ["-f", "/opt/haproxy/etc/haproxy.cfg"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb"
}
]
}
这个配置是用于调试环境下的,执行二进制程序环境的命令,以及使用的调试工具gdb/lldb。