解决 OpenSSL library not found 或者 Your OpenSSL headers do not match your library. Check config.log for details.

报错如下:

1
2
3
4
5
checking OpenSSL header version... 1010107f (OpenSSL 1.1.1g  21 Apr 2020)
checking for OpenSSL_version... no
checking for OpenSSL_version_num... no
checking OpenSSL library version... not found
configure: error: OpenSSL library not found.

或者:

1
2
3
4
5
6
7
8
9
10
11
12
checking for openssl... /usr/local/bin/openssl
checking for openssl/opensslv.h... yes
checking OpenSSL header version... 30000000 (OpenSSL 3.0.0 7 sep 2021)
checking for OpenSSL_version... yes
checking for OpenSSL_version_num... yes
checking OpenSSL library version... 1010104f (OpenSSL 1.1.1d 10 Sep 2019)
checking whether OpenSSL's headers match the library... no
configure: error: Your OpenSSL headers do not match your
library. Check config.log for details.
If you are sure your installation is consistent, you can disable the check
by running "./configure --without-openssl-header-check".
Also see contrib/findssl.sh for help identifying header/library mismatches.

错误的原因就是找不到libcrypto.so或者该文件版本不对。

解决办法:

ssl一般默认是在/usr/local/下,编译的时候指定一下路径就可以通过了。

1
CCFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" ./configure

如果不知道具体路径可以全盘搜索libcrypto.so文件,找到对应版本,在用上述方法解决。

1
2
find / -name libcrypto.so*
#找到系统所有版本的该文件。