Solved

php configure fails on mysql support

Posted on 2011-03-06
14
952 Views
Last Modified: 2013-12-13
I'm trying to build PHP (5.3.5) on CentOS 5.5 x64 and I'm having a problem configuring PHP with MySQL support.

I have already compiled Apache (2.2.17) and installed MySQL 5.5.9 (server/client/devel/shared-compat) packages.

When I try to use configure for PHP, it terminates saying mysql configure failed; log says can't find mysqlclient.

This is the command I'm using:

./configure --with-config-file-path=/etc --with-apxs2=/usr/local/apache/bin/apxs --with-gd --enable-mbstring --with-zlib --with-jpeg-dir=lib64 --with-png-dir=lib64 --with-mysql=lib64 --with-snmp --with-ldap --with-libdir=lib64

This is what is at the end of the config.log:

configure:59658: checking for MySQL support
configure:59702: checking for specified location of the MySQL UNIX socket
configure:59900: checking for mysql_close in -lmysqlclient
configure:59919: gcc -o conftest -I/usr/include -g -O2 -fvisibility=hidden  -L/usr/lib64  conftest.c -lmysqlclient  -lldap -llber -lpng -lz -ljpeg -l\
z -lrt -lm -ldl -lnsl  -lxml2 -lz -lm -lxml2 -lz -lm 1>&5
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
configure: failed program was:
#line 59908 "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_close();

int main() {
mysql_close()
; return 0; }
configure:60142: checking for mysql_error in -lmysqlclient
configure:60161: gcc -o conftest -I/usr/include -g -O2 -fvisibility=hidden  -L/usr/lib64  -Wl,-rpath,/usr -L/usr conftest.c -lmysqlclient  -lz -lldap\
 -llber -lpng -lz -ljpeg -lz -lrt -lm -ldl -lnsl  -lxml2 -lz -lm -lxml2 -lz -lm 1>&5
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
configure: failed program was:
#line 60150 "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_error();

int main() {
mysql_error()
; return 0; }
0
Comment
Question by:Seth Simmons
  • 7
  • 7
14 Comments
 
LVL 34

Author Comment

by:Seth Simmons
ID: 35053072
After playing with it the last couple hours, fixed the problem.

Go to /usr/lib64 and do ln -s libmysqlclient.so.12 libmysqlclient.so

configure then ran fine

now make fails...

ext/mysql/.libs/php_mysql.o: In function `php_mysql_do_query_general':
/tmp/php-5.3.5/ext/mysql/php_mysql.c:1422: undefined reference to `mysql_set_server_option'
ext/mysql/.libs/php_mysql.o: In function `zif_mysql_set_charset':
/tmp/php-5.3.5/ext/mysql/php_mysql.c:1332: undefined reference to `mysql_set_character_set'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
0
 
LVL 76

Expert Comment

by:arnold
ID: 35053118
--with-mysql=/usr/lib64/mysql deals with providing a full path to where these items can be found.
more /etc/ld.so.conf.d where you can add the libraries
mysql.conf with /usr/lib/mysql /usr/lib64/mysql

etc.


0
 
LVL 34

Author Comment

by:Seth Simmons
ID: 35053410
removed the symlink; added mysql.conf with those 2 paths; ran ldconfig

configure still fails with the same error
0
 
LVL 76

Assisted Solution

by:arnold
arnold earned 500 total points
ID: 35053422
ADD LDFLAGS="-L/usr/lib64/mysql -L/usr/lib/mysql" at the begining
LDFLAGS="-L/usr/lib64/mysql -L/usr/lib/mysql" sh ./configure ..

Where did you get the install package for mysql? its libraries might be in /usr/local/lib*/mysql
run which mysql and see whether that points you to.
ps -ef | grep mysql to see is it running from /usr/local/sbin/mysql_safe
0
 
LVL 34

Author Comment

by:Seth Simmons
ID: 35056898
adding those flags made configure run fine.
should the same be added in front of make?

/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1

mysql, mysqld_safe is running from /usr/bin; packages came directly from MySQL website
0
 
LVL 76

Accepted Solution

by:
arnold earned 500 total points
ID: 35057591
There are different parameters you can use during compilation.
LDFLAGS="" defines LD related flags =-L/path/to/library/repository
CFLAGS defines parameters for the compilation process -L same as the other, -R/path/to/lib -I/path/to/include

ls -l /usr/lib64/libmysqlclient.*  /usr/lib/64/mysql/mysqlclient.*

find /usr -name "libmysqlclient*"
You should have a .a as well as .so.*
.a is used in static linking and I think this is what the issue is.
.so is used in dynamic linking.

make sure to update the /etc/ldconf.so.conf/mysql.conf by adding the location where the libmysqlclient.a can be found to the list of libraries.
and run ldconfig
0
 
LVL 34

Author Comment

by:Seth Simmons
ID: 35063668
they exist under both ./lib and ./lib64 and I have added both those paths for ld and ran ldconfig

$ cat /etc/ld.so.conf.d/mysql.conf
/usr/lib
/usr/lib64/mysql

$ find . -name "libmysqlclient*"
./lib64/libmysqlclient_r.so.12
./lib64/libmysqlclient_r.so.15
./lib64/libmysqlclient.so.12.0.0
./lib64/libmysqlclient_r.so.14.0.0
./lib64/libmysqlclient.so.12
./lib64/libmysqlclient.so.15.0.0
./lib64/libmysqlclient.so.15
./lib64/mysql/libmysqlclient.a
./lib64/mysql/libmysqlclient_r.a
./lib64/libmysqlclient.so.14
./lib64/libmysqlclient_r.so.14
./lib64/libmysqlclient_r.so.12.0.0
./lib64/libmysqlclient.so.14.0.0
./lib64/libmysqlclient_r.so.15.0.0
./lib/libmysqlclient_r.so.12
./lib/libmysqlclient.so.10.0.0
./lib/libmysqlclient_r.so.15
./lib/libmysqlclient.so.12.0.0
./lib/libmysqlclient_r.so.10
./lib/libmysqlclient_r.so.14.0.0
./lib/libmysqlclient.so.10
./lib/libmysqlclient.so.12
./lib/libmysqlclient.so.15.0.0
./lib/libmysqlclient.so.15
./lib/libmysqlclient.so.14
./lib/libmysqlclient_r.so.14
./lib/libmysqlclient_r.so.12.0.0
./lib/libmysqlclient_r.so.10.0.0
./lib/libmysqlclient.so.14.0.0
./lib/libmysqlclient_r.so.15.0.0

make still returns same error
should i try cflags in front of make?
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 76

Expert Comment

by:arnold
ID: 35070244
Did you run ldconfig after making the adjustment?  You should do
make distclean (to clear everything)
Then rerun the configure script you might want to use
sh ./configure (your set of options)
At times is you have a different shell, it may have "issues"
You should add the CFLAGS="-O2 -L -I/usr/include -I/usr/include/mysql"  and LDFLAGS
 
Do you have multiple versions of mysql on the system?
Please run
rpm -qa | grep -i mysql
0
 
LVL 34

Author Comment

by:Seth Simmons
ID: 35070690
Yes I did run ldconfig after making that change.
I have (a couple times) cleared the build folder and extracted the tarball again to start clean.
I'm using bash shell and no other mysql packages are installed.

$ rpm -qa | grep -i mysql
MySQL-shared-compat-5.5.9-1.rhel5
MySQL-shared-compat-5.5.9-1.rhel5
MySQL-client-5.5.9-1.rhel5
MySQL-server-5.5.9-1.rhel5
MySQL-devel-5.5.9-1.rhel5

When I add CFLAGS to the command line, it tells me:

checking whether the C compiler (gcc -O2 -L -l/usr/include -l/usr/include/mysql -L/usr/lib64/mysql -L/usr/lib/mysql) works... no
configure: error: installation or configuration problem: C compiler cannot create executables.


This is the command line I'm using now...in case I'm typing something wrong...

LDFLAGS="-L/usr/lib64/mysql -L/usr/lib/mysql" CFLAGS="-O2 -L -l/usr/include -l/usr/include/mysql" sh ./configure --with-config-file-path=/etc --with-apxs2=/usr/local/apache/bin/apxs --with-gd --enable-mbstring --with-zlib --with-jpeg-dir=lib64 --with-png-dir=lib64 --with-mysql=lib64 --with-snmp --with-ldap --with-libdir=lib64
0
 
LVL 76

Expert Comment

by:arnold
ID: 35071337
You can not leave a blank -L
-l is not a valid parameter either For include locatio, you need to use the capital i (I)
DFLAGS="-L/usr/lib64/mysql -L/usr/lib/mysql" CFLAGS="-O2 -L/usr/lib64/mysql -L/usr/lib/mysql -I/usr/include -I/usr/include/mysql" sh ./configure --with-config-file-path=/etc --with-apxs2=/usr/local/apache/bin/apxs --with-gd --enable-mbstring --with-zlib --with-jpeg-dir=/usr/lib64 --with-png-dir=/usr/lib64 --with-mysql=/usr/lib64/mysql --with-snmp --with-ldap --with-libdir=/usr/lib64

0
 
LVL 34

Author Comment

by:Seth Simmons
ID: 35071672
ohhh....here, the big i looked like a small L

now it can't find libjpeg...both that and the devel packages are installed.

configure: error: libjpeg.(a|so) not found.

$ rpm -qa | grep libjpeg
libjpeg-6b-37
libjpeg-6b-37
libjpeg-devel-6b-37
libjpeg-devel-6b-37

$ locate libjpeg | grep -v share
/usr/lib/libjpeg.so
/usr/lib/libjpeg.so.62
/usr/lib/libjpeg.so.62.0.0
/usr/lib64/libjpeg.so
/usr/lib64/libjpeg.so.62
/usr/lib64/libjpeg.so.62.0.0
0
 
LVL 76

Assisted Solution

by:arnold
arnold earned 500 total points
ID: 35071772
You should only add the specific --wtih-package if those resources can not be found on the system i.e. they are in a different location ie. you compiled the various required packages, but did not install them yet. This way you would point the the configure make to the ~/pre-req-package1/ as the location where this one should look for the libraries/includes it would need
 
LDFLAGS="-L/usr/lib64/mysql -L/usr/lib/mysql" CFLAGS="-O2 -L/usr/lib64/mysql -L/usr/lib/mysql -I/usr/include -I/usr/include/mysql" sh ./configure --with-config-file-path=/etc --with-apxs2=/usr/local/apache/bin/apxs --with-gd --enable-mbstring --with-zlib --with-jpeg --with-png --with-mysql --with-snmp --with-ldap
0
 
LVL 34

Author Comment

by:Seth Simmons
ID: 35072107
You need to specify dir when enabling jpeg/png support.

http://www.php.net/manual/en/image.installation.php

If I use that command without dir, configure finishes saying --with-jpeg and --with-png are unknown configuration options.

I figured out that issue... /usr/lib64 won't work with dir option; just lib64 is sufficient.
make and make install ran without errors

this ended up being the working command line:

LDFLAGS="-L/usr/lib64/mysql -L/usr/lib/mysql" CFLAGS="-O2 -L/usr/lib64/mysql -L/usr/lib/mysql -I/usr/include -I/usr/include/mysql" sh ./configure --with-config-file-path=/etc --with-apxs2=/usr/local/apache/bin/apxs --with-gd --enable-mbstring --with-zlib --with-jpeg-dir=lib64 --with-png-dir=lib64 --with-mysql --with-snmp --with-ldap
0
 
LVL 76

Expert Comment

by:arnold
ID: 35072288
I thought that a plain --with-jpeg and --with-png was an option.
Great to hear that it worked.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now