How to solve `configure: error: Cannot find OpenSSL's <evp.h>`?

Im trying to recompile PHP, but ./configure fails at :

configure: error: Cannot find OpenSSL's <evp.h>

I have LibSSL 1.0.0, LibSSL 0.9.8, LibSSL-Dev, OpenSSL installed.

--with-openssl=/usr/include/openssl

when I try with

--with-openssl

tells me:

configure: error: Cannot find OpenSSL's libraries

Where the **** are the problem ?

P.S. Php is 5.2.5, OS is Ubuntu


Solution 1:

The same issue occurred on Ubuntu 12.04.1 LTS and it was solved by issuing:

sudo apt-get install libcurl4-openssl-dev pkg-config

Solution 2:

To build php-5.3 on Debian wheezy you need the following to fix this error.

apt-get install libssl-dev libsslcommon2-dev

Then you need to configure with the following included

./configure --with-libdir=/lib/x86_64-linux-gnu ...

Solution 3:

Assuming that you already have the OpenSSL libraries and header files (on rpm systems the latter are in the xxxx-devel package)...

The issue seems to arise from how configure resolves dependencies which are distributed around the filesystem. To compile the code, the comiler needs to know where the headers are. To link the code, the linker needs to know where the libraries are.

[colin@host]$ configure .... --with-openssl-dir=/usr/include/openssl ....
...
checking OpenSSL dir for FTP... /usr/include/openssl
checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's <evp.h>

[colin@host]$ find /usr/include -name evp.h
/usr/include/openssl/evp.h

The include directory has the include file, but pkg-config fails because the library is not in /usr/include/openssl, its in /usr/lib

Running configure again with /usr as the directory:

configure .... --with-openssl-dir=/usr ....
...
checking OpenSSL dir for FTP... /usr
checking for pkg-config... /usr/bin/pkg-config
checking for OpenSSL version... >= 0.9.6
checking for CRYPTO_free in -lcrypto... yes
...

The path passed as an argument is searched to find the relevant resources.