Cygwin编译Windows HAProxy
伸手区
这里有我已经编译完成的,可以直接下载使用
https://github.com/xjoker/HAProxyForWindows
环境准备
编译版本选择是目前最新的 2.4.7
- 下载源码 https://www.haproxy.org/download/2.4/src/haproxy-2.4.7.tar.gz
- 安装 Cygwin
其中 Cygwin 需要安装下列 Package
版本可以自己选择,我列出我选择的版本号
- cmake (3.20.0-1)
- gcc-core (11.2.0-1)
- cygwin32-gcc-core (6.4.0-1)
- make (4.3-1)
- mingw64-x86_64-pcre2 (10.38-1)
- mingw64-i686-pcre2 (10.38-1)
- libpcre2-devel (10.38-1)
- pcre2 (10.38-1)
- libssl-devel (1.1.1f-1)
开始编译
编译可用的参数可参考 https://github.com/haproxy/haproxy/blob/master/Makefile
或者在目录下的 Makefile 的注释内也可看
我这里使用的参数如下
- USE_PCRE2_JIT : enable JIT for faster regex on libpcre2
- USE_THREAD : enable threads support.
- USE_CRYPT_H : set it if your system requires including crypt.h
- USE_OPENSSL : enable use of OpenSSL. Recommended, but see below.
- USE_SLZ : enable slz library instead of zlib (default=enabled)
需要注意,很多可选参数在 Windows 平台上并不能使用。
编译过程一般需要 3~5 分钟,看编译机器的性能
另外如果过程中出现异常提示缺少什么库的话,就回到 Cygwin 中安装
完成后在目录下会有 haproxy.exe
将这个文件复制到单独目录里
这时候直接执行会提示缺少很多 dll
这里列举下可能需要的 dll 名称,具体 dll 可从 cygwin 目录内找到
- cygcrypto-1.1.dll
- cygpcre2-8-0.dll
- cygwin1.dll
- cyggcc_s-seh-1.dll
- cygssl-1.1.dll
- cygz.dll
如果还有缺失的可根据名称去目录拷贝出来
执行查看下