Bug #15916 PHP configure failed with MySQLi library error.
Submitted: 21 Dec 2005 20:55 Modified: 22 Jan 2007 7:25
Reporter: [ name withheld ] Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.16 OS:IBM AIX (AIX 5.2)
Assigned to: CPU Architecture:Any

[21 Dec 2005 20:55] [ name withheld ]
Description:
AIX OS: 5.2 (with 64 bit kernel enabled and JFS2 filesystem)
Machine: RS600 44P Model 170

Could not successfully configure PHP since it failed with MySQLi error...  It's not a PHP bug on this one because PHP found MySQL library but ran into problem.

PHP configure command...
--snip--
./configure --with-mysqli=/usr/local/mysql/bin/mysql_config --with-apxs2=../../apache2/bin/apxs --with-unixODBC --with-openssl --with-curl --disable-libxml --disable-dom --enable-track-vars --enable-ftp --enable-sockets
--snip--

PHP Configure's result...
--snip--
checking for mcrypt support... no
checking for mhash support... no
checking whether to include mime_magic support... no
checking for MING support... no
checking for msession support... no
checking for mSQL support... no
checking for MSSQL support via FreeTDS... no
checking for MySQL support... no
checking for specified location of the MySQL UNIX socket... no
checking for MySQLi support... yes
checking whether to enable embedded MySQLi support... no
checking for mysql_set_server_option in -lmysqlclient... no
configure: error: wrong mysql library version or lib not found. Check
config.log for more information.
--snip--

PHP's config.log result...
--snip--
configure:53543: checking for mcrypt support
configure:54372: checking for mhash support
configure:54844: checking whether to include mime_magic support
configure:55199: checking for MING support
configure:56122: checking for msession support
configure:56830: checking for mSQL support
configure:57339: checking for MSSQL support via FreeTDS
configure:57987: checking for MySQL support
configure:58033: checking for specified location of the MySQL UNIX
socket
configure:59186: checking for MySQLi support
configure:59232: checking whether to enable embedded MySQLi support
configure:59378: checking for mysql_set_server_option in -lmysqlclient
configure:59397: gcc -o conftest -g -O2  -L/usr/local/mysql/lib
-L/usr/local/mysql/lib  -L/usr/local/ssl/lib -L/usr/local/ssl/lib
-L/usr/local/lib -L/usr/local/lib -lmysqlclient -lz -lcrypt -lnsl_r -lm
conftest.c -lmysqlclient  -liconv -lssl -lcrypto -lcurl -lssl -lcrypto
-lm  -lcurl -lssl -lcrypto 1>&5
ld: 0711-317 ERROR: Undefined symbol: .mysql_set_server_option
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.
collect2: ld returned 8 exit status
configure: failed program was:
#line 59386 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error.  */
/* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
char mysql_set_server_option();

int main() {
mysql_set_server_option()
; return 0; }
--snip--

How to repeat:
1) Download MySQL from www.mysql.com with the "IBM AIX Download" section with the gzipped file under AIX 5.2 (POWER, 64-bit).

2) Download PHP 5.1.1 at www.php.net

3) Install MySQL on the AIX machine (RS6000 44P Model 170).

4) Extracted PHP on the same AIX machine.

5) Use the PHP configure command from above (Description: section).

Suggested fix:
That would be to get it to work.  

I tried to do with the MySQL source code instead after I had this problem but kept running into few different compile errors.  We had this similar compile error on older version in the past, so we're thinking about discontinuing with MySQL and start looking for a different database software.  We don't meant any harm but we can ill-afford to have continous problem like this since we dont' have problem with configuring and compiling OpenSSL, PHP, Apache, etc.  After 2 years of working with MySQl, we figured that MySQL source code is not compatible with some RS600 machines as well as some AIX versions.  Sorry about that.
[23 Dec 2005 8:34] Valeriy Kravchuk
Thank you for a problem report. Please, send the results of the following commands from your machine:

find / -name libmysqlclient* 2>/dev/null
echo $PATH
echo $LIBPATH

(Correct me if LIBPATH is not a right environment variable for AIX. I need to know, where dynamic linking libraries are supposed to be found.)
[23 Dec 2005 14:22] [ name withheld ]
>> find / -name libmysqlclient* 2>/dev/null
/usr/local/mysql-standard-5.0.16-aix5.2-powerpc-64bit/lib/libmysqlclient.a
/usr/local/mysql-standard-5.0.16-aix5.2-powerpc-64bit/lib/libmysqlclient_r.a

>> echo $PATH
/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java131/jre/bin:/usr/java131/bin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/apache2/bin

(MySQL's Bin directory was manually added, just for crontab purpose and easier use of manual command by hand)

>> echo $LIBPATH
(blank response)

---------------------------
One thing here that would help to explain the difference with PHP's configure command and the "find / -name libmysqlclient* 2>/dev/null" command.

1) I used symbolic link to make a mysql directory and link it to the pre-compiled directory.

With the ls -la command for mysql..
# ls -la /usr/local/mysql

I get this...
lrwxrwxrwx   1 root     system           53 Nov 23 11:27 /usr/local/mysql -> /usr/local/mysql-standard-5.0.16-aix5.2-powerpc-64bit

This symbolic link worked fine with older mysql version on a different machine, MySQL Version 4.0.18 when compiling PHP there 2 or 3 years ago.
[23 Dec 2005 14:34] [ name withheld ]
>> (Correct me if LIBPATH is not a right environment variable for AIX. I need to
know, where dynamic linking libraries are supposed to be found.)

LIBPATH is the common environment variable for AIX.  Since AIX 5.x is moving toward the linux style so not sure if LIBPATH is becoming a less important thing for AIX now as LIB might will be in the long run.

For our convience here, I did this command...

>> echo $LIB
(blank response)

>> I need to know, where dynamic linking libraries are supposed 
>> to be found.
What are the example of dynamic linking libraries, filenames, etc.?  So, I would know where to look.
[30 Dec 2005 18:32] Valeriy Kravchuk
I'll be able to work on this report only next week. In the meantime, can you, please, try to install and compile with 5.0.18 just released and/or with 5.0.17 compiled from sources as described in Bug #15938. Inform about the results, if anything new will be discovered...
[31 Jan 2006 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[5 May 2006 11:56] Lou Picciano
This bug persists - have reverted back to php v 5.0.4, still with no luck.

Is the issue on of incompatility with newer versions of MySQL?  (We are using 5.0.13)  A different architecture of the mysqlclient file?

Lou
[8 Nov 2006 7:42] 文 中
I met the same bug!
[8 Nov 2006 8:27] Valeriy Kravchuk
What versions of OS, MySQL server, libmysqlclient and PHP do you use?
[9 Dec 2006 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[20 Dec 2006 15:15] alex -
adding --enable-embedded-mysqli=shared to the configure command line of php seems to solve that problem.
[21 Dec 2006 10:25] Valeriy Kravchuk
All reporters:

Please, check that adding --enable-embedded-mysqli=shared to the PHP configure command line makes any difference in your cases.
[10 Jan 2007 23:02] [ name withheld ]
the --enable-embedded-mysqli=shared did nothing for me.
what fixed mine was editing the --with-mysqli to read --with-mysqli-dir=/usr/lib/mysql... or where ever your libraries are. mysql was originally installed from a centos repo and apparently does not install to the folder php has in its default settings.
[22 Jan 2007 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[22 Jan 2007 7:25] Valeriy Kravchuk
So, it looks like not a bug in MySQL code. You just have to provide proper options for configure while building PHP.
[7 May 2008 7:49] Pradeep V
Yes, i had the same issue and adding --with-mysqli-dir=/usr/lib/mysql fixed it.
[24 Jun 2010 18:33] Michael Felt
The import error message in config.log is:
configure:61242: xlc -o conftest -I/usr/include -L/usr/local/ssl/lib -L/usr/local/lib -L/u
sr/lib -L/usr/local/mysql/lib  -R/usr/local/mysql/lib -L/usr/local/mysql/lib -L/usr/lib -b
libpath:/usr/local/lib:/usr/lib:/usr/local/ssl/lib:/usr/local/mysql/lib -R/usr/local/lib -
L/usr/local/lib -R/usr/local/mysql/lib -L/usr/local/mysql/lib -lmysqld -lz -lnsl_r -lm -lr
t conftest.c -lmysqlclient  -lmysqlclient -lfreetype -lpng -lz -ljpeg -lcurl -lm  -lxml2 -
liconv -lm -lcurl -lxml2 -liconv -lm 1>&5
ld: 0706-027 The -R /usr/local/mysql/lib flag is ignored.
ld: 0706-027 The -R /usr/local/lib flag is ignored.
ld: 0706-027 The -R /usr/local/mysql/lib flag is ignored.
ld: 0706-006 Cannot find or open library file: -l mysqld

====
I spent some time looking for where the text mysqld cam from and I found this sequence in PHP configure script:
========
if test "$PHP_MYSQLI" != "no"; then

  if test "$PHP_MYSQLI" = "yes"; then
    MYSQL_CONFIG=`$php_shtool path mysql_config`
  else
    MYSQL_CONFIG=$PHP_MYSQLI
  fi

  MYSQL_LIB_NAME='mysqlclient'
  if test "$PHP_EMBEDDED_MYSQLI" = "yes"; then
    cat >> confdefs.h <<\EOF
#define HAVE_EMBEDDED_MYSQLI 1
EOF

    MYSQL_LIB_CFG='--libmysqld-libs'
  elif test "$enable_maintainer_zts" = "yes"; then
    MYSQL_LIB_CFG='--libs_r'
    MYSQL_LIB_NAME='mysqlclient_r'
  else
    MYSQL_LIB_CFG='--libs'
  fi

=======
The key line is:
   MYSQL_LIB_CFG='--libmysqld-libs'

when mysql_config is called it returns:

/usr/local/mysql/bin/mysql_config --libmysqld-libs
-Wl,-brtl  -L/usr/local/mysql/lib -lmysqld -lz -lnsl_r -lm    -lrt

And the script tries to link to a non-existing library mysqld

I'll try the solution above, or otherwise link the client library. If that does not work I'll edit the mysql_config script.

No idea if this is mysql, or php 'bug' - but at least we have the code causing the issue.