Thanks for the answer of the OP. Even after following the steps I was getting the same error. Explicitly mentioning openssl path resolved the issue.
Following is the command:
./configure --enable-optimizations --with-openssl=/usr/local/openssl-1.1.1t