While trying to build PHP 5.3.3 on Debian jessie (save yourself some sanity by not asking why) with OpenSSL extension enabled, I encountered undefined reference to symbol 'X509_free@@OPENSSL_1.0.0'
in the linking step of the Makefile and couldn't figure out why (libssl-dev
is present and libssl.so
contains the requested symbol). I tried to build the official Debian package that was included in Debian squeeze, using a pbuilder
-based chroot-environment that contains a Debian jessie and therefore newer libraries (like OpenSSL 1.0.1 instead of 0.9.8). I confirmed that PHP 5.3.3 is compatible with OpenSSL 1.0.1 by building it outside the chroot-environment using ./configure --disable-all --with-openssl=/usr; make
. The resulting CGI- and CLI-binaries are indeed linked against OpenSSL, which can be confirmed via ldd sapi/cli/php
. And yet inside the chroot-environment, it failed.
Don't bother anwering, I already figured out most of the reason and a workaround/hack to enable a successful build.
Apart from making libssl.so and libcrypto.so available in the right place (
/usr/lib/
instead of/usr/lib/x86_64-linux-gnu/
), which I had already solved via symbolic links, I had to hack around a mistake that the newly generated configure script made inside the chroot environment. Outside the chroot environment, I didn't bother recreating the configure script via./buildconf --force
and this original script works fine. But the Debian package tries to do the right thing and recreates the configure script this way before calling it. Unfortunately, the newly created configure script is very different from the original one and mistakenly determines that libcrypto.so is missing the symbolDSA_get_default_method
and thus does not add-lcrypto
to theEXTRA_LIBS
variable inside the Makefile. That is why the linking fails. The original configure script makes approximately the same test with the same library but correctly determines that the symbol is present, that's why with the original configure script linking succeeds. I assume this has to do with different autoconf versions (PHP 5.3.3 needs at least 2.63, but jessie has 2.69), but I didn't try to dig deeper because I was already fed up.Instead I simply edited the Makefiles created by the broken configure script via
sed
and added the missing-lcrypto
back to theEXTRA_LIBS
variable. The build succeeded and the resulting PHP is linked against OpenSSL 1.0.1 and can successfully open SSL connections. If you try this yourself and your server explodes, don't blame me - it's only a hack and the proper solution would be to figure out the autoconf problem.