环境
suse12.5
keepalived 2.1.5
gcc 4.0
openssl 1.0.2 和 1.1.0
报错
编译的时候报错如下
代码语言:javascript
复制
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: check/libcheck.a(check_ssl.o): in function `build_ssl_ctx':
/tmp/keepalived-2.1.5/keepalived/check/check_ssl.c:77: undefined reference to `OPENSSL_init_crypto'
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: /tmp/keepalived-2.1.5/keepalived/check/check_ssl.c:92: undefined reference to `TLS_method'
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: check/libcheck.a(check_ssl.o): in function `ssl_connect':
/tmp/keepalived-2.1.5/keepalived/check/check_ssl.c:235: undefined reference to `BIO_up_ref'
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: /tmp/keepalived-2.1.5/keepalived/check/check_ssl.c:236: undefined reference to `SSL_set0_rbio'
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: /tmp/keepalived-2.1.5/keepalived/check/check_ssl.c:237: undefined reference to `SSL_set0_wbio'
collect2: error: ld returned 1 exit status
Makefile:475: recipe for target 'keepalived' failed
make[2]: *** [keepalived] Error 1
make[2]: Leaving directory '/tmp/keepalived-2.1.5/keepalived'
Makefile:591: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/tmp/keepalived-2.1.5/keepalived'
Makefile:434: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
分析
看起来是没有安装opessl相关库,
但使用ldconfig -p的时候是能看到 ssl库信息的(有两个版本)
查看check_ssl.c 发现应该是识别到 1.1.0的版本了, 但使用的库的信息是1.0.0的
解决办法
configure前 添加 1.1.0的库的环境变量信息
代码语言:javascript
复制
export LDFLAGS="$LDFLAGS -L /usr/local/openssl-1.1.0g"
./configure --prefix=/usr/local/keepalived
make && make install