Bug #23761 Compiling PHP 5.1.6 with MySQL 5.0.27
Submitted: 30 Oct 2006 6:46 Modified: 14 Dec 2006 20:44
Reporter: William Kanoff Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.27 OS:MacOS (OS X 10.4.8)
Assigned to: Assigned Account CPU Architecture:Any

[30 Oct 2006 6:46] William Kanoff
Description:
In compiling PHP 5.1.6 I ran into the following error.  

/usr/bin/ld: warning multiple definitions of symbol _regcomp
/usr/sbin/httpd definition of _regcomp
/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../../libm.dylib(regcomp.So) definition of _regcomp
/usr/bin/ld: warning multiple definitions of symbol _regexec
/usr/sbin/httpd definition of _regexec
/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../../libm.dylib(regexec.So) definition of _regexec
/usr/bin/ld: warning multiple definitions of symbol _regfree
/usr/sbin/httpd definition of _regfree
/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../../libm.dylib(regfree.So) definition of _regfree
/usr/bin/ld: multiple definitions of symbol _CRYPTO_add_lock
/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../../libcrypto.dylib(cryptlib.o) definition of _CRYPTO_add_lock
/usr/local/mysql/lib/libmysqlclient.a(libtaocrypt_la-misc.o) definition of _CRYPTO_add_lock in section (__TEXT,__text)
/usr/bin/ld: multiple definitions of symbol _CRYPTO_lock
/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../../libcrypto.dylib(cryptlib.o) definition of _CRYPTO_lock
/usr/local/mysql/lib/libmysqlclient.a(libtaocrypt_la-misc.o) definition of _CRYPTO_lock in section (__TEXT,__text)
collect2: ld returned 1 exit status
make: *** [libs/libphp5.bundle] Error 1

This error first occured in 5.0.24 and still seems to be around.  I have to use 5.0.22 in order to compile PHP.

How to repeat:
Quicksilver 2002 800 MHz - 1.5  Gig Ram - New Install of OS 10.4.8

Install mysql 5.0.27.

Compile PHP with the following 

CFLAGS="-Wno-pointer-sign" \
./configure \
--prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/private/etc \
--disable-dependency-tracking \
--with-apxs=/usr/sbin/apxs \
--with-ldap=/usr \
--with-kerberos=/usr \
--with-openssl=/usr \
--with-zlib-dir=/usr \
--with-xml \
--with-xsl=/usr \
--with-iodbc=/usr \
--with-curl=/usr \
--with-config-file-path=/etc \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-cli \
--enable-trans-sid \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-mbregex \
--enable-dbx \
--enable-sockets

When you run make you will get an error.
[30 Oct 2006 13:20] Hartmut Holzgraefe
Which binary 5.0.27 package are you using? Or are you compiling MySQL from source? In this case i'd be interested in that configure string as well.

When compiling both from soure (using BUILD/compile-ppc-debug-max for mysql and your configure string for PHP i'm getting warnings only on the crypto symbols but the build succeeds:

/usr/bin/ld: warning suggest use of -bind_at_load, as lazy binding may result in errors or different symbols being used
symbol _CRYPTO_add_lock used from dynamic library /usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../../libcrypto.dylib(cryptlib.o) not from earlier dynamic library /usr/local/mysql-5.0.27/lib/mysql/libmysqlclient.15.dylib(libtaocrypt_la-misc.o)
symbol _CRYPTO_lock used from dynamic library /usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../../libcrypto.dylib(cryptlib.o) not from earlier dynamic library /usr/local/mysql-5.0.27/lib/mysql/libmysqlclient.15.dylib(libtaocrypt_la-misc.o)
[31 Oct 2006 4:10] William Kanoff
I was using the package for OS X 10.4, PowerPC 32-bit.
[31 Oct 2006 7:52] Hartmut Holzgraefe
verified, beaks with 10.3 and 10.4 standard packages,
but works fine (although with warnings) with BUILD/compile-ppc-debug-max
[31 Oct 2006 23:09] William Kanoff
Found a work around.  After installing the 5.0.27 10.4 standard package - 32 bit, I downloaded the tar file (5.0.27) and configured it with the following:

CFLAGS="-arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -Wno-pointer-sign" \
./configure --prefix=/usr/local/mysql \
 --localstatedir=/usr/local/mysql/data \
 --libexecdir=/usr/local/mysql/bin \
 --libdir=/usr/local/mysql/lib \
 --with-server-suffix=-standard \
 --enable-thread-safe-client \
 --enable-local-infile \
 --enable-shared \
 --with-zlib-dir=bundled \
 --with-big-tables \
 --with-readline \
 --with-archive-storage-engine \
 --with-innodb \
 --with-openssl=/usr \
 --without-docs \
 --without-bench

I then ran sudo make install.

Next I configured PHP as before and ran make with no problems, a few warnings nothing more. PHP 5.1.6 is now installed and working. 

The second install of mysql with-openssl seems to be what made it work.  Don't know why.
[6 Dec 2006 20:32] Erwin Manuel
This bug looks to be related to Bug #21930.  Seems that both libmysqlclient (Solaris 2.9 binary distribution) and OpenSSL's libcrypto are exporting the CRYPTO* functions.  This causes problems when both libraries are used in a PHP build.

The problem I have is building PHP 5.1.6, using gnu 3.4.6, MySql 5.0.27 Solaris 2.9 binary distribution, and OpenSSL 0.9.7c.

The error I get is:
ld: fatal: symbol `CRYPTO_add_lock' is multiply-defined:
        (file /erp/usr/local/mysql-standard-5.0.27-solaris9-sparc/lib/libmysqlclient.a(libtaocrypt_la-misc.o) type=FUNC; file /erp/usr/local/openssl/0.9.7c/lib/libcrypto.a(cryptlib.o) type=FUNC);
ld: fatal: symbol `CRYPTO_lock' is multiply-defined:
        (file /erp/usr/local/mysql-standard-5.0.27-solaris9-sparc/lib/libmysqlclient.a(libtaocrypt_la-misc.o) type=FUNC; file /erp/usr/local/openssl/0.9.7c/lib/libcrypto.a(cryptlib.o) type=FUNC);
ld: fatal: File processing errors. No output written to .libs/libphp5.so
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1

Quick solution to get PHP running is to remove MySql support.  Long term, download the MySql source and build the client.
[12 Dec 2006 18:10] Daniel Beckham
Mysql+SSL+PHP5 has been broken since 5.0.25.  Does the OSX build team test PHP5 with new mysql builds?  I know this sounds like an asshole question, but when PHP5  *will not* compile, release after release, it's no longer an accident or a mistake.

I have the same issue and have had it for several versions now.  The download page discourages compiling MySQL yourself, but the OS X build continues to be BROKEN and unusable by people who are using PHP 5.  Is anyone interested in fixing *and* testing MySQL with PHP 5 on OS X?

Otherwise, stop building OS X binaries.. we are having to compile them ourselves anyway.
[14 Dec 2006 20:44] Timothy Smith
This is a duplicate bug #19810.  Please see final comments on that bug for workarounds / solutions.

Regards,

Timothy