pythonpipopensslubuntu-18.04python-3.8

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


I am trying to install python3.8.2 from python source by following this link, everything works fine except ssl module.

when i try command like below.

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

config.log looks like below

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

and when i run

make -j 8

am getting error like follow

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

Solution

  • I resolved the issue by following the steps provided in in this link

    Step1:

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

    Step2:

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

    Step3:

    $ cd openssl-1.1.1g
    

    Step4:

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

    Note:

    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.

    Step5:

    $ make
    $ make test
    $ make install
    

    Then i navigate to python installed dir. followed the below steps

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