编译php7.1.4出现 undefined reference to isfinite
2017-05-04 11:32
447 查看
我在 CentOS5.5 上编译 php7.1.4 出现错误:
系统信息 :
网上找了一圈发现 GCC 4.1.2 版本还不能支持
但是我又不想升级 GCC,那是否还有其他方法呢?
经过测试, php7.1.2 之前的版本都可以编译通过,php7.1.3之后的版本一编译就报上面的错误
我的配置参数为 :
为什么 php7.1.2 可以编译通过,而 php7.1.3 之后的版本就不行了呢?
我对比了 php7.1.2 和 php7.1.3 的 config.log :
通过观察可以发现 php7.1.2 的
而 php7.1.3 之后的脚本总是检测出 gcc 能够支持
OK,那就修改
在 php7.1.3 版本你需要修改
推荐修改 php7.1.4 版本的
https://github.com/php/php-src/commit/2e8308260513015dbf80ff0239eca79dbca4f36e
修改 php7.1.4 的
将
修改之后可以看到 config.log 中
然后 make 一下,php7.1.4 果然可以正常编译了。当然这只是临时办法,还是期待 php 后续版本能修复这个问题.
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 t 4000 o `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=0 95509 else 95510 ac_have_decl=0 95511 fi 95512 95513 cat >>confdefs.h <<_ACEOF 95514 #define HAVE_DECL_ISFINITE $ac_have_decl 95515 _ACEOF 95516 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=0 95520 else 95521 ac_have_decl=0 95522 fi 95523 95524 cat >>confdefs.h <<_ACEOF 95525 #define HAVE_DECL_ISNAN $ac_have_decl 95526 _ACEOF 95527 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=0 95531 else 95532 ac_have_decl=0 95533 fi
修改之后可以看到 config.log 中
| #define HAVE_DECL_ISFINITE 0 | #define HAVE_DECL_ISNAN 0 | #define HAVE_DECL_ISINF 0
然后 make 一下,php7.1.4 果然可以正常编译了。当然这只是临时办法,还是期待 php 后续版本能修复这个问题.
相关文章推荐
- PHP 5.3.10 编译安装时出现 undefined reference to `libiconv' 错误的解决方法
- PHP 编译安装时出现 undefined reference to `libiconv' 错误的解决方法
- 编译c文件出现undefined reference to `__gxx_personality_v0'
- libvorbis编译出现undefined reference to `ogg_sync_pageseek'
- ubuntu下eclipse编译c项目出现undefined reference to `sin'
- 编译PHP错误:undefined reference to `ts_resource_ex'
- 重新编译php又出错了。undefined reference to `php_xx
- 编译出现这种错误 undefined reference to '__gxx_personality_v0'
- 用gcc编译.cpp文件可能出现"undefined reference to `__gxx_personality_v0'"问题的解决
- 编译 FFmpeg h263 decoder出现编译错误undefined reference to `ff_find_pix_fmt'
- 关于arm-linux-gcc交叉编译工具链,实现自己的crt0或者编译UBOOT出现undefined reference to `__aeabi_unwind_cpp_pr0'的解决方法
- undefined reference to `libiconv_open 无法编译PHP
- gcc编译cpp文件 出现undefined reference to `__gxx_personality_v0'
- undefined reference to `libiconv_open 无法编译PHP
- 使用NDK编译的时候出现 undefined reference to
- cocos2d-x 使用ndk编译 x86 出现 in function Curl_resolv_timeout: undefined reference to 'sigsetjmp' 错误
- 在linux上编译cppunit1.12.1出现'undefined reference to `dlclose''的解决方法
- 用gcc编译.cpp文件可能出现"undefined reference to `__gxx_personality_v0'"问题的解决
- gcc 引用math.h头文件,编译出现undefined reference to `pow‘等错误时,需要加参数-lm.
- undefined reference to `libiconv_open 无法编译PHP