获取
https://github.com/android/platform_external_libxml2/releases
编译
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk
编译错误1:host static library
错误信息:
Android.mk:99: /opt/android/android-ndk-r10d/build/core/build-host-static-library.mk: No such file or directory
make: *** No rule to make target `/opt/android/android-ndk-r10d/build/core/build-host-static-library.mk'. Stop.
处理方法:
# For the host
# ========================================================
#include $(CLEAR_VARS)
#LOCAL_SRC_FILES := $(common_SRC_FILES)
#LOCAL_C_INCLUDES += $(common_C_INCLUDES)
#LOCAL_CFLAGS += $(DISABLED_WARNING_FLAGS)
#LOCAL_SHARED_LIBRARIES += $(common_SHARED_LIBRARIES)
#LOCAL_MODULE:= libxml2
#include $(BUILD_HOST_STATIC_LIBRARY)
编译错误2: ucnv
错误信息:
./include/libxml/encoding.h:31:26: fatal error: unicode/ucnv.h: No such file or directory
处理方法:
include\libxml\xmlversion.h
#if 0
#define LIBXML_ICU_ENABLED
#endif
编译动态库
如果只是想编译动态库,只需要改
include $(BUILD_STATIC_LIBRARY)
为
include $(BUILD_SHARED_LIBRARY)
同时编译静态库和动态库
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(common_SRC_FILES)
LOCAL_C_INCLUDES += $(common_C_INCLUDES)
LOCAL_SHARED_LIBRARIES += $(common_SHARED_LIBRARIES)
LOCAL_CFLAGS += -fvisibility=hidden
LOCAL_CFLAGS += $(DISABLED_WARNING_FLAGS)
LOCAL_CFLAGS += -DLIBXML_SCHEMAS_ENABLED
LOCAL_CFLAGS += -DLIBXML_REGEXP_ENABLED
LOCAL_CFLAGS += -DLIBXML_AUTOMATA_ENABLED
LOCAL_CFLAGS += -DLIBXML_PATTERN_ENABLED
LOCAL_CFLAGS += -DLIBXML_UNICODE_ENABLED
LOCAL_CFLAGS += -DLIBXML_VALID_ENABLED
LOCAL_MODULE:= libxml2
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(common_SRC_FILES)
LOCAL_C_INCLUDES += $(common_C_INCLUDES)
LOCAL_SHARED_LIBRARIES += $(common_SHARED_LIBRARIES)
LOCAL_CFLAGS += -fvisibility=hidden
LOCAL_CFLAGS += $(DISABLED_WARNING_FLAGS)
LOCAL_CFLAGS += -DLIBXML_SCHEMAS_ENABLED
LOCAL_CFLAGS += -DLIBXML_REGEXP_ENABLED
LOCAL_CFLAGS += -DLIBXML_AUTOMATA_ENABLED
LOCAL_CFLAGS += -DLIBXML_PATTERN_ENABLED
LOCAL_CFLAGS += -DLIBXML_UNICODE_ENABLED
LOCAL_CFLAGS += -DLIBXML_VALID_ENABLED
LOCAL_MODULE:= libxml2_shared
include $(BUILD_SHARED_LIBRARY)