今天在 CentOS 7.6 上编译 HAProxy 1.9.4 版本的时候发生如下错误
[root@JasonSong haproxy-1.9.4]# make clean
[root@JasonSong haproxy-1.9.4]# make -j 8 TARGET=linux2628 USE_OPENSSL=1 USE_PCRE=1 USE_ZLIB=1
CC src/ev_poll.o
CC src/ev_epoll.o
CC src/ssl_sock.o
CC src/proto_http.o
CC src/cfgparse-listen.o
CC src/proto_htx.o
CC src/stream.o
In file included from include/types/global.h:32:0,
from src/ev_epoll.c:26:
include/types/listener.h:29:25: fatal error: openssl/ssl.h: No such file or directory
#include <openssl/ssl.h>
^
compilation terminated.
In file included from include/types/global.h:32:0,
from src/ev_poll.c:26:
include/types/listener.h:29:25: fatal error: openssl/ssl.h: No such file or directory
#include <openssl/ssl.h>
^
compilation terminated.
src/ssl_sock.c:42:24: fatal error: openssl/bn.h: No such file or directory
#include <openssl/bn.h>
^
compilation terminated.
In file included from include/types/proxy.h:34:0,
from include/proto/log.h:34,
from include/common/cfgparse.h:30,
from src/cfgparse-listen.c:14:
include/common/regex.h:31:18: fatal error: pcre.h: No such file or directory
#include <pcre.h>
要解决这个问题,你需要安装 OpenSSL 开发包,执行以下命令进行安装,然后重新编译即可解决
CentOS系统执行以下命令
[root@JasonSong haproxy-1.9.4]# sudo yum install openssl-devel
Ubuntu系统执行以下命令
[root@JasonSong haproxy-1.9.4]# sudo apt-get install libssl-dev