(OK) port_php-5.6.14_to_Android—(和lighttpd集成成功)—没有基于android 4.4源码

+++++++++++++++++++++++++++++++++++++++++编译 php-5.6.14,将用到的库静态链接进来
[root@localhost php-5.6.14]# pwd
/opt/cBPM-android/php-5.6.14
[root@localhost php-5.6.14]#

(android-ndk-r8e, androideabi-4.7, android-14)
(android-ndk-r10d, androideabi-4.9, android-14)         //本次移植采用这套组合

export NDK_ROOT="/opt/android-on-linux/android-ndk-r10d"
export SYSROOT="$NDK_ROOT/platforms/android-14/arch-arm"
export CFLAGS="-g --sysroot=$SYSROOT --pipe -I$NDK_ROOT/sources/cxx-stl/stlport/stlport -I$NDK_ROOT/platforms/android-14/arch-arm/usr/include -I$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/include -I$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.7/include-fixed -I$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.7/include -I/opt/cBPM-android/libiconv-1.14/include"
export CPPFLAGS="$CFLAGS"
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-L$NDK_ROOT/sources/cxx-stl/stlport/libs/armeabi-v7a -L/opt/cBPM-android/criteria-lin/lib -lstlport_static -liconv -lgcc -lc"
export CPATH="$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin"
export CPP="$CPATH/arm-linux-androideabi-cpp"
export CXX="$CPATH/arm-linux-androideabi-g++"
export CC="$CPATH/arm-linux-androideabi-gcc"
export LD="$CPATH/arm-linux-androideabi-ld"
export AR="$CPATH/arm-linux-androideabi-ar"

./configure --host=arm-linux-androideabi --disable-all --disable-cli --without-iconv --enable-mbstring --with-sqlite3 --enable-pdo=shared --with-pdo-sqlite=shared

ln -s /opt/android-on-linux/android-ndk-r10d/platforms/android-14/arch-arm/usr/lib/crtbegin_so.o .
ln -s /opt/android-on-linux/android-ndk-r10d/platforms/android-14/arch-arm/usr/lib/crtend_so.o .

make -j4

----------------------------------
至此,移植php成功,如果出现错误,参考本为最后面的问题解决方法
----------------------------------

----------------------------------下面将 php 复制到手机,和 lighttpd 集成

第1步:将 php 复制到手机

[root@localhost php-5.6.14]# ll sapi/cgi/php-cgi -h
-rwxr-xr-x. 1 root root 14M 10月 22 21:21 sapi/cgi/php-cgi

[root@localhost php-5.6.14]# adb push sapi/cgi/php-cgi /data/data/webserver/sbin

第2步:配置lighttpd,支持php,修改lighttpd.conf

[root@localhost lighttpd-1.4.37]# gedit ./doc/config/lighttpd.conf
末尾添加:
include "conf.d/fastcgi.conf"

[root@localhost lighttpd-1.4.37]# adb push doc/config/lighttpd.conf /data/data/www/etc/lighttpd/


第3步:配置lighttpd,支持php,修改fastcgi.conf

[root@localhost lighttpd-1.4.37]# gedit ./doc/config/conf.d/fastcgi.conf
末尾添加:
##----------------------------------------------------------------------------------
fastcgi.server = ( ".php" =>
                   ( "php-local" =>
                     (
                       "socket" => socket_dir + "/php-fastcgi-1.socket",
                       "bin-path" => "/data/data/webserver/sbin/php-cgi",
                       "max-procs" => 1,
                       "broken-scriptfilename" => "enable",
                     )
                   ),
                   ( "php-tcp" =>
                     (
                       "host" => "127.0.0.1",
                       "port" => 9999,
                       "check-local" => "disable",
                       "broken-scriptfilename" => "enable",
                     )
                   ),

                   ( "php-num-procs" =>
                     (
                       "socket" => socket_dir + "/php-fastcgi-2.socket",
                       "bin-path" => "/data/data/webserver/sbin/php-cgi",
                       "bin-environment" => (
                         "PHP_FCGI_CHILDREN" => "16",
                         "PHP_FCGI_MAX_REQUESTS" => "10000",
                       ),
                       "max-procs" => 5,
                       "broken-scriptfilename" => "enable",
                     )
                   ),
                )
##----------------------------------------------------------------------------------

[root@localhost lighttpd-1.4.37]# adb push doc/config/conf.d/fastcgi.conf /data/data/www/etc/lighttpd/conf.d/


第4步:

[root@localhost lighttpd-1.4.37]# gedit test.php
内容如下:
<?php
    phpinfo();
?>

[root@localhost lighttpd-1.4.37]# adb push test.php /data/data/www/htdocs


第5步:启动lighttpd服务器

/data/data/webserver/lighttpd -D -f /data/data/www/etc/lighttpd/lighttpd.conf -m /data/data/webserver/plugin

第6步:宿主机,浏览器:
http://192.168.0.101:8000/
http://192.168.0.101:8000/test.php


----------------------------------
至此,php 和 lighttpd 集成成功
----------------------------------



----------------------------------
移植php,问题解决方法
----------------------------------

./configure --host=arm-linux-androideabi --disable-all --enable-pdo --with-sqlite3 --with-pdo-sqlite --with-zlib --without-iconv

./configure --host=arm-linux --enable-fastcgi --enable-force-cgi-redirect --enable-discard-path --disable-cli --without-iconv --enable-mbstring --enable-pdo=shared --with-sqlite=shared --with-pdo-sqlite=shared

./configure --host=arm-linux-androideabi --disable-all --enable-fastcgi --enable-force-cgi-redirect --enable-discard-path --disable-cli --without-iconv --enable-mbstring --enable-pdo --enable-pdo=shared --with-sqlite=shared --with-pdo-sqlite=shared
----------------------------------


--------------------------------------
./configure --host="arm-linux-eabi" --enable-static --disable-shared --without-bzip2 --without-zlib
--------------------------------------
export LDFLAGS="-L$NDK_ROOT/sources/cxx-stl/stlport/libs/armeabi-v7a -L/opt/cBPM-android/criteria-lin/lib -static -lstlport_static -lgcc -lc"
export CFLAGS="-DLIGHTTPD_STATIC -g --sysroot=$SYSROOT --pipe -I$NDK_ROOT/sources/cxx-stl/stlport/stlport -I$NDK_ROOT/platforms/android-14/arch-arm/usr/include -I$NDK_ROOT/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/include -I$NDK_ROOT/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.7/include-fixed -I$NDK_ROOT/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.7/include"
--------------------------------------
[root@localhost php-5.6.14]# gedit config.h
添加:
#define HAVE_SYS_UN_H 1
[root@localhost php-5.6.14]# make -j5
--------------------------------------

[root@localhost php-5.6.14]# ll src/lighttpd
-rwxr-xr-x. 1 root root 926240 10月 20 17:02 src/lighttpd
[root@localhost php-5.6.14]#

编译完后会产生lighttpd
[root@localhost php-5.6.14]# adb push src/lighttpd /data/data/webserver

把 plugins (mod_*.so)都放到/data/data/webserver/plugin
[root@localhost php-5.6.14]# adb push src/.libs/somod /data/data/webserver/plugin
[root@localhost php-5.6.14]# adb push src/.libs/mod /data/data/webserver/plugin

[root@localhost php-5.6.14]# mv src/.libs/mod*.so src/.libs/somod
[root@localhost php-5.6.14]# ls src/.libs/        库位置

另外 libpcre.so 是需要的,请确定libpcre.so有存在。本文

------------------------------------------------
[root@localhost php-5.6.14]# ls /opt/cBPM-android/criteria-lin/lib/
Criteria.xml   helloworldcpp  libiconv.a         libLibraries.a   libsqlite.so    libWorkflowEngineD.so  
libc.so        libiconv.so.2      libLibraries.so  libstdc++.so          libxerces-c-3.1.so
executer       libdl.a        libiconv.so.2.5.1  libpcre.a        libstlport.so         libxerces-c.a
helloworld     libdl.so       libiconv.so.bac    libsqlite.a      libWorkflowEngineD.a  temp2.txt
[root@localhost php-5.6.14]#
------------------------------------------------

------------------------------------------------编译过程中出现的错误及其解决方法:

错误:
arm-linux-androideabi-g++: error: crtbegin_so.o: No such file or directory
arm-linux-androideabi-g++: error: crtend_so.o: No such file or directory
原因是ld找不到  crtbegin_so.o 和 crteng_so.o,
解决方法,在项目源码下面建立软连接
ln -s /opt/android-on-linux/android-ndk-r10d/platforms/android-14/arch-arm/usr/lib/crtbegin_so.o .
ln -s /opt/android-on-linux/android-ndk-r10d/platforms/android-14/arch-arm/usr/lib/crtend_so.o .

-----------------------
checking for iconv... no
checking for libiconv... no
configure: error: Please reinstall the iconv library.
解决方法:
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make && make install
cd ..
-----------------------
编译libiconv解决./stdio.h:1010:1: 错误: ‘gets’未声明(不在函数内)
使用较高版本的LINUX系统编译libiconv时,执行make遇到了这个错误,解决方法如下:
    cd srclib/
    sed -i -e '/gets is a security/d' ./stdio.in.h
    cd ../
    make
-----------------------
/opt/cBPM-android/php-5.6.14/ext/standard/formatted_print.c:34:36: error: 'struct lconv' has no member named 'decimal_point'
 #define LCONV_DECIMAL_POINT (*lconv->decimal_point)

解决方法:
# gedit /opt/cBPM-android/php-5.6.14/ext/standard/formatted_print.c    line: 34
# gedit /opt/cBPM-android/php-5.6.14/main/spprintf.c                line: 100
# gedit /opt/cBPM-android/php-5.6.14/main/snprintf.c                line: 45


#define LCONV_DECIMAL_POINT (*lconv->decimal_point)
替换为:
#define LCONV_DECIMAL_POINT '.'

-----------------------
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:379:21: error: storage size of 'state' isn't known
  struct __res_state state;

/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:789:21: error: storage size of 'state' isn't known
  struct __res_state state;

/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:1023:21: error: storage size of 'state' isn't known
  struct __res_state state;
解决方法:
参考http://blog.csdn.net/dadoneo/article/details/8199113 和 /usr/include/resolv.h   line:71-150  添加到 下面文件  line: 43
修改文件  /opt/android-on-linux/android-ndk-r10d/platforms/android-14/arch-arm/usr/include/resolv.h

添加具体内容如下:
//---------------------------------------------------------------------张 ztg add

#include "netinet/in.h"
#include "arpa/nameser.h"
#include "resolv.h"

/*
 * Inline versions of get/put short/long.  Pointer is advanced.
 */
#define NS_INT32SZ    4    /*%< #/bytes of data in a u_int32_t */
#define NS_INT16SZ    2    /*%< #/bytes of data in a u_int16_t */
#define NS_GET16(s, cp) do { \
    register const u_char *t_cp = (const u_char *)(cp); \
    (s) = ((u_int16_t)t_cp[0] << 8) \
        | ((u_int16_t)t_cp[1]) \
        ; \
    (cp) += NS_INT16SZ; \
} while (0)
#define NS_GET32(l, cp) do { \
    register const u_char *t_cp = (const u_char *)(cp); \
    (l) = ((u_int32_t)t_cp[0] << 24) \
        | ((u_int32_t)t_cp[1] << 16) \
        | ((u_int32_t)t_cp[2] << 8) \
        | ((u_int32_t)t_cp[3]) \
        ; \
    (cp) += NS_INT32SZ; \
} while (0)


#define    GETSHORT        NS_GET16
#define    GETLONG            NS_GET32

#define ns_c_in    1    /*%< Internet. */
#define ns_t_srv    33    /*%< Internet. */
#define C_IN        ns_c_in
#define T_SRV    ns_t_srv

#define T_A DNS_T_A
#define T_ANY DNS_T_ANY
#define T_MX DNS_T_MX
//#define C_IN 0

typedef struct HEADER {
    int qdcount;
    int ancount;
    int nscount;
    int arcount;
} HEADER;

//---------------------------------------------------------------------
上面解决了如下类似问题
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:466: error: undefined reference to 'GETSHORT'

-----------------------
/opt/cBPM-android/php-5.6.14/ext/standard/basic_functions.c:3623: error: undefined reference to 'zm_startup_password'
ext/standard/.libs/basic_functions.o:basic_functions.c:basic_functions: error: undefined reference to 'zif_password_hash'
ext/standard/.libs/basic_functions.o:basic_functions.c:basic_functions: error: undefined reference to 'zif_password_get_info'
ext/standard/.libs/basic_functions.o:basic_functions.c:basic_functions: error: undefined reference to 'zif_password_needs_rehash'
ext/standard/.libs/basic_functions.o:basic_functions.c:basic_functions: error: undefined reference to 'zif_password_verify'

/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:420: error: undefined reference to 'res_ninit'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:428: error: undefined reference to 'res_nsearch'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:434: error: undefined reference to 'res_nclose'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:466: error: undefined reference to 'GETSHORT'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:467: error: undefined reference to 'GETSHORT'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:468: error: undefined reference to 'GETLONG'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:469: error: undefined reference to 'GETSHORT'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:506: error: undefined reference to 'GETSHORT'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:592: error: undefined reference to 'GETLONG'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:594: error: undefined reference to 'GETLONG'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:596: error: undefined reference to 'GETLONG'

/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:913: error: undefined reference to 'res_ninit'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:921: error: undefined reference to 'res_nsearch'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:924: error: undefined reference to 'res_nclose'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:955: error: undefined reference to 'dn_skipname'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:959: error: undefined reference to 'res_nclose'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:1000: error: undefined reference to 'res_nclose'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:1048: error: undefined reference to 'res_ninit'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:1055: error: undefined reference to 'res_nsearch'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:1066: error: undefined reference to 'dn_skipname'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:1073: error: undefined reference to 'dn_skipname'
/opt/cBPM-android/php-5.6.14/ext/standard/formatted_print.c:261: error: undefined reference to 'localeconv'
/opt/cBPM-android/php-5.6.14/ext/standard/formatted_print.c:289: error: undefined reference to 'localeconv'
/opt/cBPM-android/php-5.6.14/main/snprintf.c:1014: error: undefined reference to 'localeconv'
/opt/cBPM-android/php-5.6.14/main/snprintf.c:1075: error: undefined reference to 'localeconv'
collect2: error: ld returned 1 exit status
make: *** [sapi/cgi/php-cgi] 错误 1
[root@localhost php-5.6.14]#

-----------------------
error: undefined reference to 'localeconv'
解决方法:
# gedit /opt/cBPM-android/php-5.6.14/main/snprintf.c
注释掉 line:1014、1075
//                            lconv = localeconv();

# gedit /opt/cBPM-android/php-5.6.14/ext/standard/formatted_print.c
注释掉 line:261、289
//            lconv = localeconv();

# gedit /opt/cBPM-android/php-5.6.14/main/spprintf.c
注释掉 line:624、684
//                            lconv = localeconv();

-----------------------
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:913: error: undefined reference to 'res_ninit'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:921: error: undefined reference to 'res_nsearch'
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:924: error: undefined reference to 'res_nclose'
...
/opt/cBPM-android/php-5.6.14/ext/standard/dns.c:1073: error: undefined reference to 'dn_skipname'

解决了如上类似问题:
# gedit /opt/cBPM-android/php-5.6.14/ext/standard/dns.c
res_ninit    替换为        __res_ninit
dn_skipname    替换为        __dn_skipname
# gedit ./ext/standard/php_dns.h
res_nsearch    替换为        __res_nsearch
res_nclose    替换为        __res_nclose
res_search    替换为        __res_search
-----------------------
/opt/cBPM-android/php-5.6.14/ext/standard/basic_functions.c:3623: error: undefined reference to 'zm_startup_password'
ext/standard/.libs/basic_functions.o:basic_functions.c:basic_functions: error: undefined reference to 'zif_password_hash'
ext/standard/.libs/basic_functions.o:basic_functions.c:basic_functions: error: undefined reference to 'zif_password_get_info'
ext/standard/.libs/basic_functions.o:basic_functions.c:basic_functions: error: undefined reference to 'zif_password_needs_rehash'
ext/standard/.libs/basic_functions.o:basic_functions.c:basic_functions: error: undefined reference to 'zif_password_verify'

解决方法参考:
https://github.com/thekid/php-src/commit/4c2b86ef006c71523ca2a8a613cc779773a2bcc6
http://blog.chinaunix.net/uid-14735472-id-5230146.html


-----------------------


阅读(232) | 评论(0) | 转发(0) |
0

上一篇:port php to android—Fix "undefined reference to zm_startup_password"

下一篇:Lighttpd 配置fastcgi

相关热门文章
  • phpStudy 下载,PHP5开发环境...
  • 为PHP添加GD库支持
  • 灵芝的种类和图片
  • yii2权限(RBAC)
  • php生成二维码的几种方式...
  • linux dhcp peizhi roc
  • 关于Unix文件的软链接
  • 求教这个命令什么意思,我是新...
  • sed -e "/grep/d" 是什么意思...
  • 谁能够帮我解决LINUX 2.6 10...
评论热议

你可能感兴趣的:((OK) port_php-5.6.14_to_Android—(和lighttpd集成成功)—没有基于android 4.4源码)