[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

php configure fails on mysql support

Posted on 2011-03-06
14
Medium Priority
?
980 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
14 Comments
 
LVL 35

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 80

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 35

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 80

Assisted Solution

by:arnold
arnold earned 2000 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 35

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 80

Accepted Solution

by:
arnold earned 2000 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 35

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
 
LVL 80

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 35

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 80

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 35

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 80

Assisted Solution

by:arnold
arnold earned 2000 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 35

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 80

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

650 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