Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6565099
  • 博文数量: 1159
  • 博客积分: 12444
  • 博客等级: 上将
  • 技术积分: 12570
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-13 21:34
文章分类

全部博文(1159)

文章存档

2016年(126)

2015年(350)

2014年(56)

2013年(91)

2012年(182)

2011年(193)

2010年(138)

2009年(23)

分类: C/C++

2015-10-19 12:24:38

http://hamer-blog.logdown.com/posts/141588-how-to-port-pcre-to-android


pcre版本是8.33, 下載link如下:

Android 版本是 4.2.1

以下方法是參考:

再加上一些些微的修正

首先把下載下來的tar檔解壓縮到android source code的external directory
設定好下面兩個環境變數

PDK_ROOT="your-android-source-root-directory" PATH=$PDK_ROOT/prebuilts/gcc/linux-x86/mips/mipsel-linux-android-4.6/bin:$PATH 

然後

./configure --host=mipsel-linux CC=mipsel-linux-android-gcc CPP=mipsel-linux-android-cpp CFLAGS="-nostdlib -DHAVE_STRERROR=1" CPPFLAGS="-I${PDK_ROOT}/development/ndk/platforms/android-9/include -I${PDK_ROOT}/bionic/libc/include/ -I${PDK_ROOT}/bionic/libc/arch-mips/include/ -I${PDK_ROOT}/bionic/libc/kernel/common/ -I${PDK_ROOT}/bionic/libc/kernel/common/linux/ -I${PDK_ROOT}/bionic/libc/kernel/arch-mips" LDFLAGS="-Wl,-rpath-link=${PDK_ROOT}/out/target/product/saturn/system/lib -L${PDK_ROOT}/out/target/product/saturn/system/lib" --enable-utf8 --enable-unicode-properties

此時會生成config.h 等其他檔案, 這時候修改config.h裡面的內容如下

/* #undef HAVE_STRERROR */ 

--->

#define HAVE_STRERROR 1 

再來就在pcre的 directory內放上Android.mk, 內容如下:

#
#  Android makefile for libpcre
#
#  This makefile generates libpcre.so, pcregrep and pcre.h ONLY.
#  It should be amended to build libpcreposix.so, libpcrecpp.so
#  and tests.  LOCAL_PATH := $(call my-dir) ###
### Build libpcre.so and pcre.h
###  include $(CLEAR_VARS) LOCAL_MODULE := libpcre LOCAL_MODULE_CLASS := SHARED_LIBRARIES LOCAL_PRELINK_MODULE := false LOCAL_MODULE_TAGS := samples intermediates := $(call local-intermediates-dir) LOCAL_SRC_FILES := \  pcre_byte_order.c \ pcre_compile.c \ pcre_config.c \ pcre_dfa_exec.c \ pcre_exec.c \ pcre_fullinfo.c \ pcre_get.c \ pcre_globals.c \ pcre_internal.h \ pcre_jit_compile.c \ pcre_maketables.c \ pcre_newline.c \ pcre_ord2utf8.c \ pcre_refcount.c \ pcre_string_utils.c \ pcre_study.c \ pcre_tables.c \ pcre_ucd.c \ pcre_valid_utf8.c \ pcre_version.c pcre_xclass.c \ ucp.h LOCAL_COPY_HEADERS := pcre.h LOCAL_CFLAGS += -O3 -I. -DHAVE_CONFIG_H GEN := $(LOCAL_PATH)/pcre_chartables.c $(GEN): $(LOCAL_PATH)/pcre_chartables.c.dist  $(hide) cp $(LOCAL_PATH)/pcre_chartables.c.dist $@ #LOCAL_GENERATED_SOURCES += $(GEN) LOCAL_SRC_FILES += pcre_chartables.c #GEN := $(LOCAL_PATH)/pcre.h
#$(GEN): $(LOCAL_PATH)/pcre.h.generic
#   $(hide) cp $(LOCAL_PATH)/pcre.h.generic $@
#LOCAL_GENERATED_SOURCES += $(GEN)  #GEN := $(LOCAL_PATH)/config.h
#$(GEN): $(LOCAL_PATH)/config.h.generic
#   $(hide) cp $(LOCAL_PATH)/config.h.generic $@
#LOCAL_GENERATED_SOURCES += $(GEN)  include $(BUILD_SHARED_LIBRARY) ###
### Build pcregrep
###  include $(CLEAR_VARS) LOCAL_MODULE := pcregrep LOCAL_SRC_FILES := pcregrep.c LOCAL_CFLAGS += -O3 -I. -DHAVE_CONFIG_H LOCAL_SHARED_LIBRARIES := libpcre LOCAL_MODULE_TAGS := samples include $(BUILD_EXECUTABLE) 

之後就可以如編譯Android的個別component一樣 mm showcommands or mm -B showcommands來編譯pcre了
到這邊就算完工



阅读(1050) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~