首页 » Linux » CentOS » Centos7编译php8.3.16版本报错解决

Centos7编译php8.3.16版本报错解决

 

Centos7版本中编译php8.3.16会报错,报错内容大致如下,8.3.16版本前不会产生该报错。

8.3.17同样会产生以下报错,理论适用于8.3.16之后的其它版本。

php-8.3.16/ext/ffi/ffi.c: In function 'zend_ffi_parse_directives':
php-8.3.16/ext/ffi/ffi.c:5047:59: error: macro "strncmp" requires 3 arguments, but only 2 given
5047 | if (strncmp(code_pos, ZEND_STRL("#define")) == 0) {
| ^
In file included from /usr/include/string.h:633,
from php-8.3.16/include/../main/php_config.h:2327,
from php-8.3.16/Zend/zend_config.h:1,
from php-8.3.16/Zend/zend_portability.h:43,
from php-8.3.16/Zend/zend_types.h:25,
from php-8.3.16/Zend/zend.h:27,
from php-8.3.16/main/php.h:31,
from php-8.3.16/ext/ffi/ffi.c:21:
/usr/include/bits/string2.h:919: note: macro "strncmp" defined here
919 | # define strncmp(s1, s2, n) \
|
php-8.3.16/ext/ffi/ffi.c:5047:61: warning: the comparison will always evaluate as 'false' for the address of strncmp' will never be NULL [-Waddress]
5047 | if (strncmp(code_pos, ZEND_STRL("#define")) == 0) {
| ^~
php-8.3.16/ext/ffi/ffi.c:5052:62: error: macro "strncmp" requires 3 arguments, but only 2 given
5052 | if (strncmp(p, ZEND_STRL("FFI_SCOPE")) == 0) {
| ^
In file included from /usr/include/string.h:633,
from php-8.3.16/include/../main/php_config.h:2327,
from php-8.3.16/Zend/zend_config.h:1,
from php-8.3.16/Zend/zend_portability.h:43,
from php-8.3.16/Zend/zend_types.h:25,
from php-8.3.16/Zend/zend.h:27,
from php-8.3.16/main/php.h:31,
from php-8.3.16/ext/ffi/ffi.c:21:
/usr/include/bits/string2.h:919: note: macro "strncmp" defined here
919 | # define strncmp(s1, s2, n) \
|
php-8.3.16/ext/ffi/ffi.c:5052:64: warning: the comparison will always evaluate as 'false' for the address of strncmp' will never be NULL [-Waddress]
5052 | if (strncmp(p, ZEND_STRL("FFI_SCOPE")) == 0) {
| ^~
php-8.3.16/ext/ffi/ffi.c:5056:67: error: macro "strncmp" requires 3 arguments, but only 2 given
5056 | } else if (strncmp(p, ZEND_STRL("FFI_LIB")) == 0)

报错原因分析

php-8.3.16引入的代码更改对于已经结束生命周期的CentOS 7的glibc 2.17版本是不兼容的,这导致在CentOS 7(el7) 操作系统上编译php-8.3.16及更高版本失败。而AlmaLinux或Rocky Linux 8和9系统则没有问题,因为它们使用的是新的glibc版本。

解决办法:

通过下载补丁进行导入,补丁下载地址

http://down.whsir.com/downloads/php83-ffi-c7.patch

解压缩php-8.3.17.tar.gz,进入php-8.3.17目录下,将补丁放进来,然后导入补丁

最后make clean重新编译即可

我更推荐大家使用wlnmp源进行安装,无需这么繁琐的编译过程,仅需两部即可完成php安装

1、添加wlnmp源

2、安装php

使用参考:https://www.wlnmp.com/install

原文链接:Centos7编译php8.3.16版本报错解决,转载请注明来源!

0