64位Ubuntu 14.04上使用musleabi最小化交叉编译Android版PHP7

php中文网
发布: 2016-06-23 13:05:23
原创
1952人浏览过

https://bitbucket.org/GregorR/musl-cross/downloads
crossx86-arm-linux-musleabi-0.9.11.tar.xz (20MB)

CC=arm-linux-musleabi-gcc \
CXX=arm-linux-musleabi-g++ \
AR=arm-linux-musleabi-ar \
LD=arm-linux-musleabi-ld \
RANLIB=arm-linux-musleabi-ranlib \
STRIP=arm-linux-musleabi-strip \
CFLAGS="-Os" \
CXXFLAGS="-Os" \
./configure \
--host=arm-linux-musleabi \
--prefix=/opt/phpdroid/php \
--disable-all \
--enable-json \
--enable-pdo \
--with-sqlite3 \
--with-pdo-sqlite

PHP源代码自带PCRE库,编译时不依赖外部PCRE库,所以不需要额外编译PCRE库和配置CPPFLAGS和LDFLAGS参数:
CPPFLAGS="-I/png/dev/android/compiled/usr/include -I/png/dev/android/compiled/usr/usr/include" \
LDFLAGS="-static -L/png/dev/android/compiled/usr/lib -L/png/dev/android/compiled/usr/usr/lib" \

sed -i "s{/bin/sh{/system/bin/sh{" ext/standard/proc_open.c
sed -i "s{-export-dynamic{-all-static{" Makefile

立即学习PHP免费学习笔记(深入)”;

问小白
问小白

免费使用DeepSeek满血版

问小白 5331
查看详情 问小白

缺 sed -i "s{-export-dynamic{-all-static{" Makefile 编译后:
./php -v 返回 -bash: ./php: No such file or directory
file ./php 返回 php: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), stripped
正常应该返回 php: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), statically linked, stripped

time nice -20 make -j2
make install

arm-linux-musleabi-strip /opt/phpdroid/php/bin/php
xz -z -k -9 /opt/phpdroid/php/bin/php
strip后不到4MB,xz压缩后约1MB.
比现在php.xz的3.7MB小了2.7MB, PHPDroid APK包能从5.7MB缩小到3MB.
下载: php-7.0.6-arm-linux.xz(1.1MB)

./php -m
[PHP Modules]
Core
date
json
pcre
PDO
pdo_sqlite
Reflection
SPL
sqlite3
standard

./php -r 'print_r(get_defined_functions());' > func.txt
./php -r 'print_r(get_declared_classes());' > class.txt
可见包含了下面常用到的一些功能:
pdo_sqlite
json_encode/json_decode
file_get_contents/file_put_contents
注意:没有OpenSSL支持,file_put_contents是不支持HTTPS协议的.
./php -r "file_put_contents('logo.gif',file_get_contents('https://www.baidu.com/img/bdlogo.gif'));"

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号