这几天在折腾把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"
编译成功!!!!
其实问题很简单,对于有经验的老手根本不是问题。但是对于我这种摸索着前进的来说,碰壁也算是成长了吧!