13

I was trying to build PHP 5.2.17 from source on Ubuntu 12.4 64bit using this configuration:

./configure --prefix=/opt/php5.2 --with-config-file-path=/opt/php5.2 --with-mysql 

but I keep getting this error:

configure: error: Cannot find libmysqlclient under /usr.
Note that the MySQL client library is not bundled anymore!

Any Idea how to resolve this?

EDIT1: I minimized the configure command so it just focuses to mysql. also I'm running a 64bit version of ubuntu.

EDIT2: tried running ldconfig -v |grep mysql and here is the output

# ldconfig -v |grep mysql
/sbin/ldconfig.real: Path `/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Cannot stat /usr/lib/x86_64-linux-gnu/libnss_db.so: No such file or directory
libmysqlclient.so.18 -> libmysqlclient_r.so.18.0.0
libmysqlpp.so.3 -> libmysqlpp.so.3.1.0
farzam
  • 709
  • 2
  • 6
  • 21
  • 1
    I *guess* you need to tell configure where the directory of it is. - Looks like this is not a question but a Google request: [php configure: cannot find libmysqlclient](http://www.linuxquestions.org/questions/linux-server-73/php-configure-cannot-find-libmysqlclient-582944/) (search: PHP configure libmysqlclient path). – hakre Jun 21 '12 at 08:25
  • Do you have any idea where it is located? I tried finding it and here is the result: `./usr/share/doc/libmysqlclient-dev ./usr/share/doc/libmysqlclient18 ./usr/lib/x86_64-linux-gnu/libmysqlclient.so ./usr/lib/x86_64-linux-gnu/libmysqlclient.a ./usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.18 ./usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.18.0.0 ./usr/lib/x86_64-linux-gnu/libmysqlclient_r.so ./usr/lib/x86_64-linux-gnu/libmysqlclient_r.a ./usr/lib/x86_64-linux-gnu/libmysqlclient.so.18.0.0 ./usr/lib/x86_64-linux-gnu/libmysqlclient.so.18 ... – farzam Jun 21 '12 at 08:29
  • @hakre I will edit the question and will add additional info. – farzam Jun 21 '12 at 08:49
  • @hakre I minimized the configure command. thanx for the tip. – farzam Jun 21 '12 at 09:03
  • PHP 5.2 is no longer being updated. I suggest you upgrade to 5.3 at the very least. – GordonM Jun 21 '12 at 09:07
  • 2
    @GordonM I'm completly aware that 5.2 is no supported. but I have to have this on my machine to support legacy scripts. my question is not about which version is supported. it is just about having the 5.2 version running on ubuntu 12. I had managed to have php5.2 and php5.3 on ubuntu 11.10 – farzam Jun 21 '12 at 09:10
  • @hakre I edited the question with the output of that command – farzam Jun 21 '12 at 09:14
  • Thanx @hakre for the assistance. I managed to get it working. – farzam Jun 21 '12 at 09:17
  • 3
    @fkniya: You should not care about a single downvote too much. Sometimes users here feel that the question is not appropriate or you haven't done enough to research the issue. I think it's important that you take care that question and answer are of general use, e.g. add some more general information so it's clear how you solved the error message. – hakre Jun 21 '12 at 09:24

2 Answers2

21

Thanx @hakre for the assistance. here is the command I used and it works:

sudo ./configure --prefix=/opt/php5.2 --with-config-file-path=/opt/php5.2 --with-mysql --with-libdir=/lib/x86_64-linux-gnu
farzam
  • 709
  • 2
  • 6
  • 21
  • How did you find out that it must be `--with-libdir=/lib/x86_64-linux-gnu`? I mean the exact path. I only see the path inside the error messages of the `# ldconfig -v | grep mysql` output, but it has other paths, too. – hakre Jun 21 '12 at 09:22
  • I knew that I should use `--with-libdir` param and just tried that path. – farzam Jun 21 '12 at 09:25
  • 3
    @hakre use `locate libmysqlclient` to find out where your files are and then specify the exact location. – tony gil Oct 11 '12 at 13:23
  • 3
    Thanks for this. Just to note on my install if it helps anyone, the locate shows its in /usr//lib/x86_64-linux-gnu but it says missing still if I include the /usr in front, so it does seem to use the path relative to /usr. – Ian Mar 10 '15 at 16:59
  • If somoone use RHEL 7 (in my case) the libdir path is --with-libdir=/lib64/ – Daniel Kennedy May 21 '20 at 17:55
5

Maybe for some poor soul this will work:

./configure --with-apxs2=/usr/sbin/apxs --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd

Brongadier
  • 159
  • 1
  • 12
  • You saved my poor soul :) – The Unique Paul Smith Apr 04 '16 at 14:15
  • Thanks! It worked for me too. Was stuck with compiling php 5.3.29 for phpfarm usage. It's using multiple php engines at apache at the same time. Some instructions here: https://gist.github.com/gmodarelli/5887778 – liberborn Jun 27 '16 at 21:30
  • Awesome!! PHP v 5.3.27 on Ubuntu14, I had to modify it a bit: ./configure --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd – George Mylonas Feb 09 '17 at 16:55
  • For the question, my resolution is the as one in this answer. At some point --with-libdir=XXX not worked for me. – Juriy Apr 01 '17 at 18:24