我在 CentOS5.5 上编译 php7.1.4 出现错误:

ext/standard/.libs/var.o: In function `php_var_export_ex':
/PHP/32/source/php7.1.4_zts/ext/standard/var.c:473: undefined reference to `isfinite'
main/.libs/php_variables.o: In function `zend_dval_to_lval':
/PHP/32/source/php7.1.4_zts/Zend/zend_operators.h:117: undefined reference to `isfinite'
Zend/.libs/zend_operators.o: In function `zendi_smart_strcmp':
/PHP/32/source/php7.1.4_zts/Zend/zend_operators.c:2789: undefined reference to `isfinite'
Zend/.libs/zend_operators.o: In function `zend_dval_to_lval':
/PHP/32/source/php7.1.4_zts/Zend/zend_operators.h:117: undefined reference to `isfinite'
/PHP/32/source/php7.1.4_zts/Zend/zend_operators.h:117: undefined reference to `isfinite'
Zend/.libs/zend_operators.o:/PHP/32/source/php7.1.4_zts/Zend/zend_operators.h:117: more undefined references to `isfinite' follow
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1

系统信息 :

[root@localhost]# cat /etc/issue
CentOS release 5.5 (Final)
Kernel \r on an \m[root@localhost]# 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@localhost]# 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@localhost]# 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@localhost]# 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.

网上找了一圈发现 GCC 4.1.2 版本还不能支持 isfinite, GCC4.3.3 才开始支持 isfinite.

但是我又不想升级 GCC,那是否还有其他方法呢?

经过测试, php7.1.2 之前的版本都可以编译通过,php7.1.3之后的版本一编译就报上面的错误

我的配置参数为 :

./configure --prefix=/target/php --with-config-file-path=/target/php/etc --enable-maintainer-zts --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session

为什么 php7.1.2 可以编译通过,而 php7.1.3 之后的版本就不行了呢?

我对比了 php7.1.2 和 php7.1.3 的 config.log :

>>> php7.1.2 config.log
configure:95485: checking for isfinite
configure:95485: gcc -m32 -o conftest -I/usr/include -g -O2 -fvisibility=hidden -pthread  -D_REENTRANT  conftest.c  >&5
/tmp/ccsJhzxB.o: In function `main':
/usr/local/src/php-7.1.2/conftest.c:514: undefined reference to `isfinite'
.....
ac_cv_func_isfinite=no>>> php7.1.3 config.log
configure:95505: checking whether isfinite is declared
configure:95505: gcc -m32 -c -I/usr/include -g -O2 -fvisibility=hidden -pthread  -D_REENTRANT conftest.c >&5
configure:95505: $? = 0
.....
#define HAVE_DECL_ISFINITE 1
.....
ac_cv_have_decl_isfinite=yes

通过观察可以发现 php7.1.2 的 configure 脚本可以正确检测 gcc 是否支持 isfinite

而 php7.1.3 之后的脚本总是检测出 gcc 能够支持 isfinite

OK,那就修改 configure 使其认为 gcc 不支持 isfinite 是否就行了呢?

在 php7.1.3 版本你需要修改configure文件使其没有定义 HAVE_DECL_ISFINITE 等几个宏才可以

推荐修改 php7.1.4 版本的 configure 文件,因为 php7.1.4 打过一个补丁

https://github.com/php/php-src/commit/2e8308260513015dbf80ff0239eca79dbca4f36e

修改 php7.1.4 的 configure 文件的 95508、95519 和 95530 行

ac_have_decl=1 修改为 ac_have_decl=0

 95505  ac_fn_c_check_decl "$LINENO" "isfinite" "ac_cv_have_decl_isfinite" "#include <math.h>95506  "95507  if test "x$ac_cv_have_decl_isfinite" = xyes; then :95508    ac_have_decl=1    #修改为 ac_have_decl=095509  else95510    ac_have_decl=095511  fi95512  95513  cat >>confdefs.h <<_ACEOF95514  #define HAVE_DECL_ISFINITE $ac_have_decl95515  _ACEOF95516  ac_fn_c_check_decl "$LINENO" "isnan" "ac_cv_have_decl_isnan" "#include <math.h>95517  "95518  if test "x$ac_cv_have_decl_isnan" = xyes; then :95519    ac_have_decl=1    #修改为 ac_have_decl=095520  else95521    ac_have_decl=095522  fi95523  95524  cat >>confdefs.h <<_ACEOF95525  #define HAVE_DECL_ISNAN $ac_have_decl95526  _ACEOF95527  ac_fn_c_check_decl "$LINENO" "isinf" "ac_cv_have_decl_isinf" "#include <math.h>95528  "95529  if test "x$ac_cv_have_decl_isinf" = xyes; then :95530    ac_have_decl=1    #修改为 ac_have_decl=095531  else95532    ac_have_decl=095533  fi

修改之后可以看到 config.log 中

| #define HAVE_DECL_ISFINITE 0
| #define HAVE_DECL_ISNAN 0
| #define HAVE_DECL_ISINF 0

然后 make 一下,php7.1.4 果然可以正常编译了。当然这只是临时办法,还是期待 php 后续版本能修复这个问题.

编译php7.1.4出现 undefined reference to isfinite相关推荐

  1. 编译出错libicui18n.so.58: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8‘

    编译出错libicui18n.so.58: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8' 环境 Ubun ...

  2. Mingw-W64编译Windows程序提示:undefined reference to `__imp_GetStockObject' 的解决方法

    gcc(Mingw-W64)编译windows程序,提示undefined reference to `__imp_GetStockObject' 的解决方法:加上-mwindows,问题解决. #i ...

  3. Android系统编译so库提示error undefined reference to '__android_log_print问题的解决

    在系统源代码的hardware/qcom下增加psam文件夹,编译源代码要生成libpsam.so库,Android.mk内容 LOCAL_PATH := $(call my-dir) include ...

  4. 【ffmpeg】编译时报错:error: undefined reference to `av...

    1.问题描述 昨天使用ffmpeg库编译demo一切正常,今天再次链接ffmpeg库时报了一堆错误: error: undefined reference to `av_frame_alloc()' ...

  5. linux c 编译报错 Compile error : undefined reference to‘__atomic_fetch_add_4’ 解决方法

    代码如下: #include <opencv2/opencv.hpp> using namespace cv;int main() {Mat img=imread("cornea ...

  6. linux中sqlite3编译时出错,Sqlite3 交叉编译 undefined reference to `fdatasync' 错误解决

    交叉编译sqlite到Android平台, Android.mk 文件内容如下: LOCAL_PATH:= $(call my-dir) INCDIR:=/home/android-ndk-r6b/s ...

  7. 编译opencv4.2时出现undefined reference to `jpeg_default_qtables‘错误的解决方案

    操作系统:kylinV10 opencv版本:4.2.0 在编译opencv4.2.0的版本时,出现undefined reference to `jpeg_default_qtables'的错误提示 ...

  8. 编译tslib1.4出现错误undefined reference to rpl_malloc错误

    编译tslib1.4时可能会出现错误undefined reference to rpl_malloc这个错误 解决方法是,在tslib目录下找到config.h.in这个文件,打开,注释掉#unde ...

  9. [CentOS]CentOS下编译CPP文件时报错[undefined reference to `__gxx_personality_v0' collect2: ld]的解决办法...

    在CentOS环境下编译CPP时报出 undefined reference to `__gxx_personality_v0' collect2: ld 以上错误,调查了一下,加上参数[-lstdc ...

  10. QT编译出错解决 libQtCore.so: undefined reference to `QInotifyFileSystemWatcherEngine::create()'

    可能出错1: libQtCore.so: undefined reference to `QInotifyFileSystemWatcherEngine::create()' 解决办法: vi ./s ...

最新文章

  1. jmeter之图片上传
  2. linux ubi 分区,Linux最新UBI文件系统介绍
  3. pyspark distinct代码示例
  4. 关于Direct2D
  5. python3字符串属性(二)
  6. 如何修复XML内存“泄漏”
  7. Python+pandas+matplotlib控制不同曲线的属性
  8. 解决HttpServletRequest InputStream只能读取一次问题
  9. 计算机考研调剂技巧,关于考研调剂的不可不知的窍门
  10. 【Excel-2010】VLOOKUP函数
  11. 身份证号码前六位查询表
  12. 实对称矩阵 二次型 合同 相似对角化
  13. CU的递归划分详细介绍
  14. 二分法的适用范围及通用代码
  15. 新词发现-helloNLP
  16. 企业级反向代理 Haproxy
  17. 合肥工业大学计算机与信息学院复试,合肥工业大学计算机与信息学院2018考研大纲(复试)...
  18. JS统计页面访问时长
  19. 消息称GPhone今日发布 揭秘幕后教父(图)
  20. 如何安装鸿蒙应用,华为鸿蒙OS系统手机怎么安装第三方的应用程序?

热门文章

  1. 微信公众平台开发[6] —— 微信开发集成类的使用
  2. 艾司博讯:拼多多推广计划点击价格设置
  3. alex机器人 ser_基于Web Service的机器人远程控制系统设计
  4. 电脑自带热点,去打不开热点(解决方案)
  5. 关于先有鸡还是先有蛋问题的科学的探讨
  6. MySQL锁与事务知识结构脑图
  7. 基于可变部件模型(DPM)的车辆行人检测
  8. CodeLite 16.0可以编译通过,但是在编辑器界面会显示找不到标准库头文件
  9. 简单例子学习理解Rough Set的范畴概念
  10. 苹果麦克风设置在哪里_这一份 iOS 14 安全和隐私设置指南,请收好