Warm tip: This article is reproduced from serverfault.com, please click

Error compiling SSL module for Python3.9 on Debian8 64b

发布于 2021-11-04 13:32:51

I need to build python3.9 on a GNU/Linux Debian8 64b system

I got the source code for the 3.9.7 version and compiled it, but I got the following error regarding the ssl module:

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

fair enough: I downloaded the openssl code from github, checkout the tag OpenSSL_1_1_1l and installed it in a local path;

  • re-configured the python 3.9 source tree
./configure --enable-optimizations --prefix=/opt/python3.9 --enable-shared --with-openssl=/root/develop/iQAC/openssl-1.1.1
  • checked the config.log file to verify it really found the new openssl installation
configure:17478: checking for openssl/ssl.h in /root/develop/iQAC/openssl-1.1.1
configure:17485: result: yes
configure:17501: checking whether compiling and linking against OpenSSL works
Trying link with OPENSSL_LDFLAGS=-L/root/develop/iQAC/openssl-1.1.1/lib; OPENSSL_LIBS=-lssl -lcrypto; OPENSSL_INCLUDES=-I/root/develop/iQAC/openssl-1.1.1/include
configure:17523: gcc -pthread -o conftest  -I/root/develop/iQAC/openssl-1.1.1/include   -L/root/develop/iQAC/openssl-1.1.1/lib conftest.c -lssl -lcrypto -lcrypt -lpthread -ldl  -lutil -lm >&5
configure:17523: $? = 0
configure:17525: result: yes
configure:17548: checking for X509_VERIFY_PARAM_set1_host in libssl
configure:17577: gcc -pthread -o conftest  -I/root/develop/iQAC/openssl-1.1.1/include   -L/root/develop/iQAC/openssl-1.1.1/lib conftest.c -lssl -lcrypto -lcrypt -lpthread -ldl  -lutil -lm >&5
configure:17577: $? = 0
configure:17588: result: yes

so, as far as I understand, I should be able to correctly link openssl 1.1.1 to my python 3.9 build, still, I'm getting the same error regarding the openssl version

Any suggestion of what I'm doing wrong and/or what I can do to complete the compilation process?

Update #1

  • tried to run the following command, trying to outsmart the Makefiles ;)
OPENSSL_LDFLAGS='-L/root/develop/iQAC/openssl-1.1.1/lib' OPENSSL_LIBS=-lssl OPENSSL_INCLUDES=-I/root/develop/iQAC/openssl-1.1.1/include make -j 3

still no success

Update #2

inspected the compile log in detail and actually the build itself is not really failing; also the include and lib paths for openssl-1.1.1 are correct:

building '_ssl' extension
gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden -fprofile-generate -I./Include/internal -I/root/develop/iQAC/openssl-1.1.1/include -I./Include -I. -I/usr/include/x86_64-linux-gnu -I/usr/local/include -I/root/develop/iQAC/build-folder/Python-3.9.7/Include -I/root/develop/iQAC/build-folder/Python-3.9.7 -c /root/develop/iQAC/build-folder/Python-3.9.7/Modules/_ssl.c -o build/temp.linux-x86_64-3.9/root/develop/iQAC/build-folder/Python-3.9.7/Modules/_ssl.o
gcc -pthread -shared -fprofile-generate build/temp.linux-x86_64-3.9/root/develop/iQAC/build-folder/Python-3.9.7/Modules/_ssl.o -L/root/develop/iQAC/openssl-1.1.1/lib -L. -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -lssl -lcrypto -o build/lib.linux-x86_64-3.9/_ssl.cpython-39-x86_64-linux-gnu.so
Questioner
sergico
Viewed
0
sergico 2021-11-06 18:46:27

After more trial and errors I succeed in building all python 3.9 modules

Actually what I did was just changing the configure options from:

./configure --enable-optimizations --prefix=/opt/python3.9 --enable-shared --with-openssl=/root/develop/iQAC/openssl-1.1.1

to

./configure --enable-optimizations --prefix=/opt/python3.9 --with-openssl=/root/develop/iQAC/openssl-1.1.1 --with-computed-gotos --enable-loadable-sqlite-extensions --enable-shared

At this point is sounds to me like an issue in the confiugration/build system, but I'm not sure about that. Comments are welcome