Compile php with mysqli support

I am trying to compile php 5.3.8 with mysqli support (mysql 5.5)  (mysql has been compile from source aswell)
this is the compile source

./configure --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --enable-mbstring --with-gd --with-zlib --with-jpeg-dir --with-png-dir --with-openssl --with-curl --with-mcrypt --with-imap --with-imap-ssl --with-kerberos --with-mysqli=/usr/local/mysql/bin/mysql_config

buts its comming with bellow error

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.

Now i have create symlink to
ln -s /usr/local/mysql/lib/ /usr/local/lib/

 ln -s /usr/local/mysql/lib/ /usr/lib/

but cant get rid of the error
i can see its due to environmental variable..
but dont understand .. how to solved it ..
can any one please help me  ..

LVL 29
Who is Participating?
export LD_LIBRARY_PATH=/usr/local/mysql/lib:$LD_LIBRARY_PATH

make sure you do not have two versions of mysql installed or your /usr/lib is the path where the compiler/linker is looking for the libraries you are trying to include.

Bad practice to create symlinks as you've done.

check /etc/ and make sure it has /usr/local/mysql/lib
Open the "config.log" and try to find the exact error.

You can post here to us look too.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

fosiul01Author Commented:
@dbauermann ;

configure:61239: checking for mysql_set_server_option in -lmysqlclient
configure:61258: gcc -o conftest -I/usr/include -g -O2 -fvisibility=hidden  -Wl,-rpath,/usr/local/mysql/lib -L/usr/local/mysql/lib -L/usr/lib  -Wl,-rpath,/usr/kerberos/lib64 -L/usr/kerberos/lib64 -Wl,-rpath,/usr/local/mysql/lib -L/usr/local/mysql/lib -lmysqlclient -lz -lm -lrt -ldl conftest.c -lmysqlclient  -lmysqlclient -lmcrypt -lltdl -lcrypt -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl  -lxml2 -lz -lm -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lssl -lcrypto -ldl -lz -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz -lxml2 -lz -lm -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lssl -lcrypto -ldl -lz 1>&5
/usr/bin/ld: skipping incompatible /usr/lib/ when searching for -lm
/usr/bin/ld: skipping incompatible /usr/lib/libm.a when searching for -lm
/usr/bin/ld: skipping incompatible /usr/lib/ when searching for -lrt
/usr/bin/ld: skipping incompatible /usr/lib/librt.a when searching for -lrt
/usr/bin/ld: skipping incompatible /usr/lib/ when searching for -ldl
/usr/bin/ld: skipping incompatible /usr/lib/libdl.a when searching for -ldl
/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
configure: failed program was:
#line 61247 "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() {
; return 0; }


if you read my post.. i had created symlink... but no luck ..

may be i am not creating in right directory.
the article. you sent its not that clear ..
can you be little bit more specifi please
Do you have the "glibc" installed in your system?

The compiler didn't find libraries that are in glibc package (in my system).
fosiul01Author Commented:
yes, its installed

Package glibc-2.5-65.x86_64 already installed and latest version
Package glibc-2.5-65.i686 already installed and latest version
Redhat-like (with RPM) or Debian-like (with apt-get)?
fosiul01Author Commented:
as you can see, its already installed (its centos)
Try to execute this command:

rpm -qal | grep "libm.a"

If the result has a line with "/usr/lib/libm.a", then list the contet of "/etc/".
fosiul01Author Commented:
[root@hostphp-5.3.8]# rpm -qal | grep "libm.a"
[root@posrep php-5.3.8]# cat /etc/
fosiul01Author Commented:
i will delete those symlinks!!

but i dont have any file

what to do with that ?
You don't have "--with-mysqli" in your configure string - why?
fosiul01Author Commented:
sorry what you meant ???

i do have ,

./configure --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --enable-mbstring --with-gd --with-zlib --with-jpeg-dir --with-png-dir --with-openssl --with-curl --with-mcrypt --with-imap --with-imap-ssl --with-kerberos --with-mysqli=/usr/local/mysql/bin/mysql_config
I would try using:
fosiul01Author Commented:
but accordign to php document

it say to use --with-mysqli=/path/to/mysql_config

its php 5.3.8
Take a look at:

[xterm@foo php-5.3.8]$ ./configure --help | grep -A2 mysqli
  --with-mysqli[=FILE]    Include MySQLi support.  FILE is the path
                          to mysql_config.  If mysqlnd is passed as FILE,
                          the MySQL native driver will be used [mysql_config]
  --enable-embedded-mysqli  MYSQLi: Enable embedded support
                            Note: Does not work with MySQL native driver!

The native driver doesn't seem to be working for you, that's why I'm suggesting trying the embedded instead.
fosiul01Author Commented:
by adding

export LD_LIBRARY_PATH=/usr/local/mysql/lib:$LD_LIBRARY_PATH

its compied ..

let it finished fully then i will be able to tell
> configure: error: wrong mysql library version or lib not found. Check config.log for more information.

I should've noticed that from the beginning, good catch.  That will actually probably work fine.

Keep in mind now that you may have to now add that export command to your Apache startup scripts, or you can create a file called mysql in /etc/ and put "/usr/local/mysql/lib" in it, and then run /sbin/ldconfig
If you do not have mysql.conf or mysql-i386.conf or mysql-i686.conf or however centos/redhat include those settings
add one mysql.conf and set the path as /usr/local/mysql/lib and that should do it..

when done run ldd php and see whether it finds the mysql related linked/shared libraries in /usr/local/mysql/lib or it references a /usr/lib/mysql location.
IMHO, if you compile your own apps, try to avoid having the same apps from the distro. The difficulty is that at times there are distro apps that rely on other distro apps.

In your case, it seems you want the newer version of PHP versus sticking with the version that comes with the OS distro you are using. Having the latest and greatest at times is not the optimal thing.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.