libxml是C语言写的xml解析库,是我们开发可移植程序的首选,下面讲述将其移植到android的步骤
1.下载已经配置好的源代码包android_libxml2.rar
http://pan.baidu.com/s/1sjpusFj
该包里还有libxml2所依赖的字符转码库libiconv,也是配置好了的。我们所做的就是先编译
libiconv,然后再编译libxml2,当然一块编译也是可以的。
2.先把libiconv改名为jni,用命令行进入当前目录,执行ndk-build
3.在把libxml2改名为jni,用命令行进入当前目录,执行ndk-build
4.在obj/local/armeabi下就会生成我们需要的静态库了
下面献上libxml2和libiconv的mk文件:
#libiconv.mk##################################
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS := \
-Wno-multichar \
-DANDROID \
-DLIBDIR="c" \
-DBUILDING_LIBICONV \
-DIN_LIBRARY
LOCAL_SRC_FILES := \
libcharset/lib/localcharset.c \
lib/iconv.c \
lib/relocatable.c
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/libcharset \
$(LOCAL_PATH)/lib \
$(LOCAL_PATH)/libcharset/include \
$(LOCAL_PATH)/srclib
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libiconv
include $(BUILD_STATIC_LIBRARY)
#libxml2.mk##################################
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
c14n.c catalog.c chvalid.c debugXML.c dict.c DOCBparser.c \
encoding.c entities.c error.c globals.c hash.c HTMLparser.c \
HTMLtree.c legacy.c list.c nanoftp.c nanohttp.c parser.c \
parserInternals.c pattern.c relaxng.c SAX.c SAX2.c \
threads.c tree.c trionan.c triostr.c uri.c valid.c\
xinclude.c xlink.c xmlIO.c xmlmemory.c xmlmodule.c \
xmlreader.c xmlregexp.c xmlsave.c xmlschemas.c xmlschemastypes.c xmlstring.c \
xmlunicode.c xmlwriter.c xpath.c xpointer.c
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/include/libxml\
$(LOCAL_PATH)/../libiconv/include \
$(LOCAL_PATH)/../libiconv \
$(LOCAL_PATH)/../libiconv/libcharset \
$(LOCAL_PATH)/../libiconv/lib \
$(LOCAL_PATH)/../libiconv/libcharset/include
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_TAGS := optional
LOCAL_CFLAGS := -L$(LOCAL_PATH)\
-L$(LOCAL_PATH)/../obj/local/armeabi
LOCAL_STATIC_LIBRARIES := iconv
LOCAL_MODULE:=libxml2
include $(BUILD_STATIC_LIBRARY)