PHP无法在MySQL 5.5版本以后通过编译
在FreeBSD里升级php5-extensions的过程中,出现mysqli无法正常进行编译,错误提示:
===> Building for php5-mysqli-5.2.12_2
/bin/sh /usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli/libtool --mode=compile cc -I. -I/usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli -DPHP_ATOM_INC -I/usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli/include -I/usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli/main -I/usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/local/include/mysql -DHAVE_CONFIG_H -O2 -pipe -fno-strict-aliasing -c /usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli/mysqli.c -o mysqli.lo
mkdir .libs
cc -I. -I/usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli -DPHP_ATOM_INC -I/usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli/include -I/usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli/main -I/usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/local/include/mysql -DHAVE_CONFIG_H -O2 -pipe -fno-strict-aliasing -c /usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli/mysqli.c -fPIC -DPIC -o .libs/mysqli.o
/usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli/mysqli.c: In function 'zm_startup_mysqli':
/usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli/mysqli.c:637: error: 'MYSQL_RPL_MASTER' undeclared (first use in this function)
/usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli/mysqli.c:637: error: (Each undeclared identifier is reported only once
/usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli/mysqli.c:637: error: for each function it appears in.)
/usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli/mysqli.c:638: error: 'MYSQL_RPL_SLAVE' undeclared (first use in this function)
/usr/ports/databases/php5-mysqli/work/php-5.2.12/ext/mysqli/mysqli.c:639: error: 'MYSQL_RPL_ADMIN' undeclared (first use in this function)
*** Error code 1
1 error
*** Error code 1
Stop in /usr/ports/databases/php5-mysqli.
===>>> make failed for databases/php5-mysqli
===>>> Aborting update
===>>> Update for databases/php5-mysqli failed
===>>> Aborting update
原因:这是mysql的一个bug,http://bugs.php.net/bug.php?id=46207&edit=1 ,已经提交了。
解决:
修改/usr/local/include/mysql/mysql.h文件内容:
enum mysql_protocol_type
{
MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
};
----------------------------==添加的内容开始==-------------------------------------
enum mysql_rpl_type
{
MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN
};
----------------------------==添加的内容结束==--------------------------------------
typedef struct character_set
{
unsigned int number;
unsigned int state;
const char *csname;
const char *name;
将以上蓝色的部分内容,添加到mysql.h文件对应的位置,重新编译即可。
NND,害得我差点就重装mysql了。
我改了后依然还有(其它类似)问题,最后不得已改用了PHP5.3,在PHP5.3编译中顺利通过。