编译PHP报错configure error Cannot find libmysqlclient under usr的解决方法

yipeiwu_com5年前Mysql基础

今天在64位Red Hat Enterprise Linux AS release 4 .7上编译PHP5.2.6出错,mysql是使用的RPM方式安装的,PHP编译代码如下:

./configure --prefix=/usr/local/php --with-mysql --with-apxs2=/usr/local/apache/bin/apxs --with-openssl --with-curl --enable-xml --with-mcrypt --with-ttf --enable-magic-quotes --enable-fastcgi --enable-mbstring --with-iconv --enable-mbstring --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --enable-sysvsem出现以下错误:checking for specified location of the MySQL UNIX socket... no
checking for MySQL UNIX socket location... no
configure: error: Cannot find libmysqlclient under /usr.
Note that the MySQL client library is not bundled anymore!

通过查找libmysqlclient,发现是在/usr/lib64/mysql/目录内的libmysqlclient.so.16.0.0做的软连接,PHP默认是去的 /usr/lib/搜索,所以没有找到.找到问题了就好解决了.

类似的问题还有:

/usr/lib/libjpeg.so -> /usr/lib64/libjpeg.so

解决方法:

1.

cp -rp /usr/lib64/mysql/libmysqlclient.so.16.0.0 /usr/lib/libmysqlclient.so

2.

/usr/lib64/libmysqlclient.so -> libmysqlclient.so.16.0.0/usr/lib/libmysqlclient.so -> /usr/lib64/libmysqlclient.so
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

经过测试后, 发现如下解决方案:

(php-xxxxx为php文件名, 代表路径)

# cd /usr/local/src/php-xxxxx/ext/mysqli
# yum -y install mysql-devel
# /phpize
# ./configure –with-php-config= /php-config –enable-embedded-mysqli=shared –enable-shared
# make
# make install

这时屏幕会打印mysqli.so生成的路径, 在php.ini里加载就好啦

/usr/bin/ld: cannot find -lmysqlclient

相关文章

Mysql数据库操作类( 1127版,提供源码下载 )

Mysql.class.php 下载 复制代码 代码如下: <?php class Mysql { private $db_host; //主机地址 private $db_use...

PHP正确配置mysql(apache环境)

写了一个测试mysql的php文件如下: 复制代码 代码如下: <?php $link=mysql_connect('localhost','root','root'); if(!...

在php和MySql中计算时间差的方法详解

在php中计算时间差有时候是件麻烦的事!不过只要你掌握了日期时间函数的用法那这些也就变的简单了。 最近在研究自己爱围脖的时候就要计算到恋爱天数,这需要php根据每天的日期进行计算,下面就...

查找mysql字段中固定字符串并替换的几个方法

我们的要求是,把地址字段的中国去掉,并跟据地址字段来设置所属省份的(province_id) 字段。 第一、替找字符串,我们可以用mysql里的replace 这个用法,本博也有提到。详...

教你如何快捷的使用cmd访问mysql小技巧

教你如何快捷的使用cmd访问mysql小技巧

以window7为例,右击“计算机” - 单击“属性” - 单击“高级系统设置” - 单击“环境变量”,剩下看图: <图1> 右下角"环境变量". <图2>选择...