php7交叉编译开启curl就报错的问题解决

这几天在折腾把php7移植到arm开发板中去,在几乎不加任何扩展的情况下,使用如下指令成功编译且顺利的移植到了开发板。(当然这个过程中还遇到了其他的坑,这个以后再说)。

./configure --host=arm-none-linux \
	--prefix=/usr/arm  \
	--disable-all \
	--enable-fpm  \
	--enable-session \
	--enable-tokenizer \
	--with-zlib   \
	--without-iconv \
	--without-libxml \
	--enable-json  \
	--with-openssl  \
	CC=arm-none-linux-gnueabi-gcc \
	CXX=arm-none-linux-gnueabi-g++ \
	CPPFLAGS="-I/hdd/zlib -I/usr/arm/include -I/hdd/usr/includes -L/usr/arm/lib"

那好吧,curl也一起编译移植吧!增加了选项--with-curl且把curl编译后的so库放在了对应的位置。

./configure --host=arm-none-linux \
	--prefix=/usr/arm  \
	--disable-all \
	--enable-fpm  \
	--enable-session \
	--enable-tokenizer \
	--with-zlib   \
	--without-iconv \
	--without-libxml \
	--enable-json  \
	--with-openssl  \
	--with-curl \
	CC=arm-none-linux-gnueabi-gcc \
	CXX=arm-none-linux-gnueabi-g++ \
	CPPFLAGS="-I/hdd/zlib -I/usr/arm/include -I/hdd/usr/includes -L/usr/arm/lib"

结果…

.......省略不知道多少行.....

/hdd/php/php-7.4.9/include/../main/php_config.h:9:19: error: expected declaration specifiers before '__attribute__'
 # define ZEND_API __attribute__ ((visibility("default")))
                   ^
/hdd/php/php-7.4.9/Zend/zend_ini.h:95:1: note: in expansion of macro 'ZEND_API'
 ZEND_API ZEND_INI_DISP(display_link_numbers);
 ^
/hdd/php/php-7.4.9/include/../main/php_config.h:9:19: error: expected declaration specifiers before '__attribute__'
 # define ZEND_API __attribute__ ((visibility("default")))
                   ^
/hdd/php/php-7.4.9/Zend/zend_ini.h:160:1: note: in expansion of macro 'ZEND_API'
 ZEND_API ZEND_INI_MH(OnUpdateBool);
 ^
/hdd/php/php-7.4.9/include/../main/php_config.h:9:19: error: expected declaration specifiers before '__attribute__'
 # define ZEND_API __attribute__ ((visibility("default")))
                   ^
/hdd/php/php-7.4.9/Zend/zend_ini.h:161:1: note: in expansion of macro 'ZEND_API'
 ZEND_API ZEND_INI_MH(OnUpdateLong);
 ^
/hdd/php/php-7.4.9/include/../main/php_config.h:9:19: error: expected declaration specifiers before '__attribute__'
 # define ZEND_API __attribute__ ((visibility("default")))
                   ^
/hdd/php/php-7.4.9/Zend/zend_ini.h:162:1: note: in expansion of macro 'ZEND_API'
 ZEND_API ZEND_INI_MH(OnUpdateLongGEZero);
 ^
/hdd/php/php-7.4.9/include/../main/php_config.h:9:19: error: expected declaration specifiers before '__attribute
.......省略不知道多少行.....

因为日志太快太多,终端只能显示后面的部分,所以根据后面的错误去百度,一直找不到所以然。心想,一定是前面的某个错误导致了后面的错误。于是再重新编译,有输出后马上截止,终于让我截到了前几行,找到了关键信息:

.......省略不知道多少行.....
cc1: warning: include location "/usr/include/x86_64-linux-gnu" is unsafe for cross-compilation
.......省略不知道多少行.....
/usr/include/x86_64-linux-gnu/sys/cdefs.h:492:49:
.......省略不知道多少行.....

为什么会使用x86的头文件呢?是不是某个地方设置了引用路径?于是利用shell在目录下查找,发现
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-bLBldBLo-1598931661140)(/upload/20200901/d84caf769e56cf2bc19c06838a23a393.png)]
终于醍醐灌顶,拨云见日!
原来开启CURL会自动设置CURL_CFLAGS但是默认的位置是主机的目录。。啊这。。。

最终命令:

./configure --host=arm-none-linux \
	--prefix=/usr/arm  \
	--disable-all \
	--enable-fpm  \
	--enable-session \
	--enable-tokenizer \
	--with-zlib   \
	--without-iconv \
	--without-libxml \
	--enable-json  \
	--with-openssl  \
	--with-curl \
	CC=arm-none-linux-gnueabi-gcc \
	CXX=arm-none-linux-gnueabi-g++ \
	CURL_CFLAGS="-I/usr/arm/include" \ //<----------------这里
	CPPFLAGS="-I/hdd/zlib -I/usr/arm/include -I/hdd/usr/includes -L/usr/arm/lib"

编译成功!!!!

其实问题很简单,对于有经验的老手根本不是问题。但是对于我这种摸索着前进的来说,碰壁也算是成长了吧!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值