星期五, 十二月 13, 2013

规则表达开源库PCRE向Android下的移植步骤 window 下mingw64 gcc/g++ 4.8.1

pcre向Android下的移植 window 下mingw64 4.8.1

该编译需要在msys环境下运行,所以必须准备的环境是:
1.Android ndk (我使用的是android ndk r9b )
2.msys (http://www.mingw.org/wiki/MSYS)下载http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe。安装到d:\msys
3.下载 pcre 8.33包www.pcre.org
4.展开pcre 8.33 包pcre-8.33.zip 到d:\
 以下是步骤。

1.准备独立的android ndk toolchain,
D:\Android\android-ndk-r9b\build\tools\make-standalone-toolchain.bat --platform=android-9 --install-dir=d:\temp\my-toolchain --toolchain=arm-linux-androideabi-4.8
2.进入 msys shell 通过桌面快捷方式或者d:\msys\1.0\msys.bat都可以.
 运行mount 可以看到系统的各个盘被映射的方式 window d:盘 映射为  /d
3.将目录输入到PATH里
 export PATH=/d/temp/my-toolchina/bin:/d/msys/1.0/bin/
./configure --host=arm-linux-androideabi --prefix=G:/William_Wang/pcre-8.33 
--disable-shared --enable-newline-is-anycrlf --enable-utf8 --enable-unicode-properties
$ make #等待稍长时间后,在.libs目录下生成了.a静态库和.so后缀的动态库,由于--disable-shared禁止了动态库,所以只有.a的静态库了
$ make install 
此时在pcre-8.33目录下生成了android 命令行程序 pcretest
adb push pcretest /sdcard/temp/然后adb shell 进入超级用户后,如果手机已经root了,可以chmod 755 pcretest 权限后,直接运行。
即可。

PCRE configure 参数清单
 
 
 

    Build 8 bit pcre library ........ : yes --disable-pcre8
    Build 16 bit pcre library ....... : no --enable-pcre16
    Build 32 bit pcre library ....... : no --enable-pcre32
    Build C++ library ............... : yes --disable-cpp
    Enable JIT compiling support .... : no --enable-jit
    Enable UTF-8/16/32 support ...... : yes --enable-utf8
    Unicode properties .............. : yes --enable-unicode-properties
    Newline char/sequence ........... : anycrlf --enable-newline-is-anycrlf
    \R matches only ANYCRLF ......... : no --enable-bsr-anycrlf
    EBCDIC coding ................... : no   --enable-ebcdic
    EBCDIC code for NL .............. : n/a --enable-ebcdic-nl25
    Rebuild char tables ............. : no   --enable-rebuild-chartables
    Use stack recursion ............. : yes --disable-stack-for-recursion
    POSIX mem threshold ............. : 10 --with-posix-malloc-threshold=20
    Internal link size .............. : 2 --with-link-size=2
    Match limit ..................... : 10000000 --with-match-limit=10000000
    Match limit recursion ........... : MATCH_LIMIT --with-match-limit-recursion=10000
    Build shared libs ............... : no --disable-shared
    Build static libs ............... : yes --disable-static
    Use JIT in pcregrep ............. : no --disable-pcregrep-jit
    Buffer size for pcregrep ........ : 20480 --with-pcregrep-bufsize=20K
    Link pcregrep with libz ......... : no --enable-pcregrep-libz
    Link pcregrep with libbz2 ....... : no --enable-pcregrep-libbz2
    Link pcretest with libedit ...... : no --enable-pcretest-libedit
    Link pcretest with libreadline .. : no --enable-pcretest-libreadline
    Valgrind support ................ : no --enable-valgrind
    Code coverage ................... : no --enable-coverage
 
 Libraries (lib):
    libpcre16     (if 16-bit character support support is enabled)
    libpcre32     (if 32-bit character support support is enabled)
    libpcre       (if 8-bit support is enabled)
    libpcreposix  (if 8-bit support is enabled)
    libpcrecpp    (if 8-bit and C++ support is enabled)
The following table shows the different representations of a few characters in comparison:
Unicode code point
U+0041
U+00DF
U+6771
U+10400
Representative glyph
UTF-32 code units
00000041
000000DF
00006771
00010400
UTF-16 code units
0041
00DF
6771
D801DC00
UTF-8 code units
41
C39F
E69DB1
F0909080
参考个选项意义:
http://www.pcre.org/pcre.txt