puma.rb: symbol lookup error: xxx/puma_http11.so: undefined symbol: OPENSSL_init_ssl
ruby /usr/local/rvm/gems/ruby-2.4.9/bin/puma -C /home/wwwroot/redis.com.cn/puma.rb: symbol lookup error: /usr/local/rvm/gems/ruby-2.4.9/gems/puma-5.0.4/lib/puma/puma_http11.so: undefined symbol: OPENSSL_init_ssl
或者
current directory: /usr/local/rvm/gems/ruby-2.4.9/gems/openssl-2.2.0/ext/openssl
make "DESTDIR="
compiling openssl_missing.c
In file included from /usr/local/include/openssl/bn.h:20:0,
from /usr/local/include/openssl/engine.h:18,
from openssl_missing.c:14:
openssl_missing.c: 在函数‘ossl_HMAC_CTX_new’中:
openssl_missing.c:65:43: 错误:invalid application of ‘sizeof’ to incomplete type ‘HMAC_CTX’
HMAC_CTX *ctx = OPENSSL_malloc(sizeof(HMAC_CTX));
出错原因是puma的使用的openssl版本库和系统中的openssl版本不一致。
通过ldd /usr/local/rvm/gems/ruby-2.4.9/gems/puma-5.0.4/lib/puma/puma_http11.so我们可以查到依赖的.so版本
libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007fd152ffd000)
ll /usr/lib64/libssl.so.10
lrwxrwxrwx 1 root root 27 11月 26 22:37 /usr/lib64/libssl.so.10 -> /usr/lib64/libssl.so.1.0.2k
可以看到程序依赖的版本是openssl 1.0.2k,而头文件 /usr/local/include/openssl 目录是1.1.1d。
动态链接库和头文件的版本不一致,所以会导致找不到对应的方法。
解决办法是备份/usr/local/include/openssl,重新下载1.0.2k的openssl,安装新的头文件。
1 2 3 4 5 6 7 8 9 10 11 |
wget http://www.openssl.org/source/openssl-1.0.2k.tar.gz tar -zxvf openssl-1.0.2k.tar.gz cd openssl-1.0.2k/ ./Configure linux-x86_64 make cd /usr/local/include/ mv openssl/ opensslbak1.1.1 cp -r /usr/local/src/openssl-1.0.2k/include/openssl ./ rvm install 2.4.2 gem install puma puma |