你的位置:首页 > 服务器类
近期打算把线上的php版本全部更新为php7版本,在CentOS 6 和CentOS 7 上编译都很顺利,在其中一台比较古老的CentOS5上编译php7.1.6出现以下错误:
ext/standard/.libs/var.o: In function `php_var_export_ex': /home/centos/2017/php7.1.6/ext/standard/var.c:473: undefined reference to `isfinite' main/.libs/php_variables.o: In function `zend_dval_to_lval': /home/centos/2017/php7.1.6/Zend/zend_operators.h:117: undefined reference to `isfinite' Zend/.libs/zend_operators.o: In function `zendi_smart_strcmp': /home/centos/2017/php7.1.6/Zend/zend_operators.c:2789: undefined reference to `isfinite' Zend/.libs/zend_operators.o: In function `zend_dval_to_lval': /home/centos/2017/php7.1.6/Zend/zend_operators.h:117: undefined reference to `isfinite' /home/centos/2017/php7.1.6/Zend/zend_operators.h:117: undefined reference to `isfinite' Zend/.libs/zend_operators.o:/home/centos/2017/php7.1.6/Zend/zend_operators.h:117: more undefined references to `isfinite' follow collect2: ld returned 1 exit status make: *** [sapi/cli/php] Error 1
系统信息:
[root@t 2017]# cat /etc/redhat-release CentOS release 5.11 (Final) [root@t 2017]# gcc --version gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [root@t 2017]# ldd --version ldd (GNU libc) 2.5 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Roland McGrath and Ulrich Drepper. [root@t 2017]# autoconf --version autoconf (GNU Autoconf) 2.59 Written by David J. MacKenzie and Akim Demaille. Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [root@t 2017]# m4 --version GNU M4 1.4.5 Written by Rene' Seindal. Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
在谷歌搜索了一下,发现这个问题已经有人向官方反馈了,https://bugs.php.net/bug.php?id=74265 官方答复gcc版本太老,建议升级gcc,不过最后一条回复的人尝试修改了configure文件在CentOS 5编译通过,
[2017-05-04 02:02 UTC] letshi at 163 dot com I try modify PHP7.1.4 configure file. I modify lineno 95508 95519 95530 modify ac_have_decl=1 to ac_have_decl=0 Compile Success On CentOS5.5 (gcc version 4.1.2)
于是按照他说的方法尝试一下,修改 php7.1.6 的configure文件的 95509、95520、95531行,把ac_have_decl=1修改为ac_have_decl=0。
95508 if test "x$ac_cv_have_decl_isfinite" = xyes; then : 95509 ac_have_decl=0 95510 else 95511 ac_have_decl=0 95512 fi 95513 95514 cat >>confdefs.h <<_ACEOF 95515 #define HAVE_DECL_ISFINITE $ac_have_decl 95516 _ACEOF 95517 ac_fn_c_check_decl "$LINENO" "isnan" "ac_cv_have_decl_isnan" "#include <math.h> 95518 " 95519 if test "x$ac_cv_have_decl_isnan" = xyes; then : 95520 ac_have_decl=0 95521 else 95522 ac_have_decl=0 95523 fi 95524 95525 cat >>confdefs.h <<_ACEOF 95526 #define HAVE_DECL_ISNAN $ac_have_decl 95527 _ACEOF 95528 ac_fn_c_check_decl "$LINENO" "isinf" "ac_cv_have_decl_isinf" "#include <math.h> 95529 " 95530 if test "x$ac_cv_have_decl_isinf" = xyes; then : 95531 ac_have_decl=0 95532 else 95533 ac_have_decl=0 95534 fi 95535
修改之后再次尝试编译通过
[root@t 2017]# /usr/local/php716/bin/php -v PHP 7.1.6 (cli) (built: Jun 9 2017 14:38:09) ( ZTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.6, Copyright (c) 1999-2017, by Zend Technologies
当然这只是临时解决方法,有时间尝试一下升级gcc到新版本,看看是不是一劳永逸。

- 发表评论
- 查看评论
【暂无评论!】发表评论: