Bug #28480 error when compiling php 5.2.2 with --with-mysql
Submitted: 16 May 2007 20:03 Modified: 18 May 2007 16:27
Reporter: Juan Montesinos Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:mysql-5.0.26-12 OS:Linux (OpenSUSE 10.2 AMD64)
Assigned to: Sveta Smirnova CPU Architecture:Any
Tags: MySQL, php

[16 May 2007 20:03] Juan Montesinos
Description:
I have an issue when trying to compile PHP 5.2.2 with "--with-mysql" flag enabled; I searched for several suggested solutions in the web but unfortunately the problem persist.
The php's configure script is the following:

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-pgsql --with-pear --with-openssl --with-zlib --with-bz2 --with-gd --with-ttf --with-png-dir --with-jpeg-dir --with-gettext --with-ldap --with-imap-ssl --with-msql --with-unixODBC=/usr/ --with-libxml-dir --enable-zip

the config.log has the following:
///////////////////////////////////////

#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_close();

int main() {
mysql_close()
; return 0; }
configure:58449: checking for mysql_error in -lmysqlclient
configure:58468: gcc -o conftest -I/usr/include -g -O2  -L/usr/lib  -Wl,-rpath,/usr/local/Hughes/lib -L/usr/local/Hughes/lib -Wl,-rpath,/usr -L/usr conftest.c -lmysqlclient  -lz -lmsql -lldap -llber -lpng -lz -ljpeg -lbz2 -lz -lresolv -lm -ldl -lnsl  -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lxml2 -lz -lm 1>&5
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: cannot find -lmsql
collect2: ld returned 1 exit status
configure: failed program was:
#line 58457 "configure"
#include "confdefs.h"

////////////////////////////////////////

Operative System: OpenSUSE 10.2 X86_64
Processor: 2 AMD64 opteron 64 bits
Server: Dell Poweredge SC1436

Then I found a suggestion of solution, only changing the flag from "--with-mysql" to "--with-mysqli=/usr/bin/mysql_config" and the warning is:
...
...
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.
////////////

The config.log file has:
////////////////////
configure:59167: checking whether to enable embedded MySQLi support
configure:59317: checking for mysql_set_server_option in -lmysqlclient
configure:59336: gcc -o conftest -I/usr/include -g -O2  -Wl,-rpath,/usr/lib64/mysql -L/usr/lib64/mysql -L/usr/lib  -Wl,-rpath,/usr/local/Hughes/lib -L/usr/local/Hughes/lib -lmysqlclient -lz -lcrypt -lnsl -lm conftest.c -lmysqlclient  -lmsql -lldap -llber -lpng -lz -ljpeg -lbz2 -lz -lresolv -lm -ldl -lnsl  -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lxml2 -lz -lm 1>&5
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: cannot find -lmsql
collect2: ld returned 1 exit status
configure: failed program was:
#line 59325 "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; }
///////////////////////////

I think this is a mysql issue.

How to repeat:
Mysql was installed from the rpm's of suse's cds, the version is:
virtual1:/tmp/php-5.2.2 # rpm -q mysql
mysql-5.0.26-12

I downloaded PHP 5.2.2 from php.net and tried to compile and the results are showed above.

Suggested fix:
I'll be thankful for your help.
[16 May 2007 22:03] Sveta Smirnova
Thank you for the report.

But version 5.0.26 is quite old. Please try with current MySQL 5.0.41 and if you can repeat described behaviour send us result of the command /usr/bin/mysql_config
[17 May 2007 1:35] Juan Montesinos
Hello,

I just installed the version 5.0.41 and the results of the command mysql_config are the following:
//////////////////////////////////
virtual1:/usr/bin # /usr/local/mysql/bin/mysql_config
Usage: /usr/local/mysql/bin/mysql_config [OPTIONS]
Options:
        --cflags         [-I/usr/local/mysql/include/mysql]
        --include        [-I/usr/local/mysql/include/mysql]
        --libs           [-L/usr/local/mysql//lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm]
        --libs_r         [-L/usr/local/mysql//lib/mysql -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread]
        --socket         [/usr/local/mysql/tmp/mysql.sock]
        --port           [3306]
        --version        [5.0.41]
        --libmysqld-libs [-L/usr/local/mysql//lib/mysql -lmysqld -lz -lpthread -lcrypt -lnsl -lm -lpthread -lrt]
///////////////////////////////

I tried to compile again php but the problem persist, could you please help me?
the configure script is:
Please be aware that I installed mysql on the path /usr/local/mysql

Waiting your comments, thank you
[17 May 2007 1:38] Juan Montesinos
Sorry, I forgot the configure script:

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-pgsql --with-pear --with-openssl --with-zlib --with-bz2 --with-gd --with-ttf --with-png-dir --with-jpeg-dir --with-gettext --with-ldap --with-imap-ssl --with-msql --with-unixODBC=/usr/ --with-libxml-dir --enable-zip

The results were:
...
...
checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... no
checking for MySQL UNIX socket location... no
configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!
...
...

If you need more information, don't hesitate to request it.
[17 May 2007 7:01] Sveta Smirnova
Thank you for the feedback.

But you didn't indicate path to MySQL installation directory in the configure string. Please indicate paths correctly and report if you meet error. Note you should use --with-mysql=/path/to/mysql/installation/dir, but --with-mysqli=/path/to/mysql_config

In your initial post like bug looks only error with --with-mysqli=/usr/bin/mysql_config configure option.
[18 May 2007 0:18] Juan Montesinos
Hello Sveta,

Sorry for the delay, here are the results using the 1st parameter:
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-pgsql --with-pear --with-openssl --with-bz2 --with-gd --with-ttf --with-png-dir --with-jpeg-dir --with-gettext --with-ldap --with-imap-ssl --with-msql --with-unixODBC=/usr/ --with-libxml-dir --enable-zip

////////////////////////
...
...
checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... no
checking for MySQL UNIX socket location... no
checking for mysql_close in -lmysqlclient... no
checking for mysql_error in -lmysqlclient... no
configure: error: mysql configure failed. Please check config.log for more information.
///////////////////

Also I used the 2nd parameter in the configure script:
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pgsql --with-pear --with-openssl --with-bz2 --with-gd --with-ttf --with-png-dir --with-jpeg-dir --with-gettext --with-ldap --with-imap-ssl --with-msql --with-unixODBC=/usr/ --with-libxml-dir --enable-zip

And the results were:
/////////////////////////
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.
////////////////////////

Thank you for your advice
[18 May 2007 12:58] Sergei Golubchik
Did you check the config.log for more information, as the error message says ?
Can you attach it to the bugreport ?

The only snippet of the config.log that you show (in the original submission) contains:

  cannot find -lmsql

because you configured with --with-msql, and you apparently don't have it.
Later you compile without mSQL, so there must be a different error now, but without a config.log it's impossible to see what it is.
[18 May 2007 16:27] Juan Montesinos
Hello Team,

I deleted the parameter "--with-msql" from the script and PHP compiled without errors now.
I don't know why happened this issue, thank you very much for your help.

Have a great day and regards from Mexico City, you can close this ticket.
[10 Nov 2007 16:12] Vikram J. Gurjar
The simplest solution to this is :

Look for a file usually called  libmysqlclient.so.15.0.0 or something like that

Link this to the /usr/lib and /usr/include (Redhat) or /usr/local/lib/ and /usr/local/include  to a file called libmysqlclient.so.15

ln -s /usr/lib/mysql/libmysqlclient.so.15.0.0 /usr/lib/libmysqlclient.so.15 
ln -s /usr/lib/mysql/libmysqlclient.so.15.0.0 /usr/include/libmysqlclient.so.15

or

ln -s /usr/lib/mysql/libmysqlclient.so.15.0.0 /usr/local/lib/libmysqlclient.so.15 
ln -s /usr/lib/mysql/libmysqlclient.so.15.0.0 /usr/local/include/libmysqlclient.so.15

It solved my problems.