Python-3.8.2 从源代码安装会导致在 python 安装中对 `SSL_new' 的未定义引用?

Python-3.8.2 installation from source causes undefined reference to `SSL_new' on python installation?

我正在尝试按照此 link 从 python 源安装 python3.8.2,一切正常,期待 ssl 模块。

当我尝试如下命令时。

./configure --with-openssl=/usr --enable-optimizations

config.log 如下所示

configure:17204: checking for openssl/ssl.h in /usr
configure:17211: result: yes
configure:17227: checking whether compiling and linking against OpenSSL works
Trying link with OPENSSL_LDFLAGS=-L/usr/lib; OPENSSL_LIBS=-lssl -lcrypto; OPENSSL_INCLUDES=- 
I/usr/include
configure:17249: gcc -pthread -o conftest  -I/usr/include   -L/usr/lib conftest.c -lssl - 
lcrypto -lcrypt -lpthread -ldl  -lutil -lm >&5
/tmp/ccnYKZ7g.o: In function `main':
conftest.c:(.text+0xa): undefined reference to `SSL_new'
collect2: error: ld returned 1 exit status

当我 运行

make -j 8

我收到如下错误

Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with 
X509_VERIFY_PARAM_set1_host().

我按照 link

中提供的步骤解决了问题

第一步:

$ wget http://www.openssl.org/source/openssl-1.1.1g.tar.gz

第 2 步:

$ tar -xf openssl-1.1.1g.tar.gz

第三步:

$ cd openssl-1.1.1g

第四步:

./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl

注:

By default openssl will be installed under /usr/local/ssl. If you do not want to mess with existing SSL installation, then install it in a different directory.

第五步:

$ make
$ make test
$ make install

然后我导航到 python 安装目录。按照以下步骤

$ ./configure --with-openssl=/usr --enable-optimizations
$ make -j 8