ref:
CSDNhttps://mp.csdn.net/mp_blog/creation/editor/121038315
1.下载源码:
git clone https://gitlab.gnome.org/GNOME/libxml2 -b v2.9.11 --depth=1
文章保存的目录为d:\tools\linux\libxml2
2.安装wsl,备注需要win10
3.下载linux版本 NDK android-ndk-r14b
本文章ndk安装的目录为d:\tools\android\sdk\ndk\linux\android-ndk-r14b
4.编写编译脚本compile_ndk14.sh for armv7a
compile_ndk14.sh存放在d:\tools\linux\libxml2目录下
##
LIBXML2_BUILD_ROOT=`pwd`
LIBXML2_ANDROID_PLATFORM=android-9
LIBXML2_BUILD_NAME=libxml2-armv7a
LIBXML2_TOOLCHAIN_PATH=$LIBXML2_BUILD_ROOT/../build/$LIBXML2_BUILD_NAME/toolchain
LIBXML2_BUILD_OUTPUT=$LIBXML2_BUILD_ROOT/../build/$LIBXML2_BUILD_NAME/output
LIBXML2_MAKE_TOOLCHAIN_FLAGS="$LIBXML2_MAKE_TOOLCHAIN_FLAGS --install-dir=$LIBXML2_TOOLCHAIN_PATH"
# Create an arm API 9 libc++ toolchain.
$ANDROID_NDK/build/tools/make_standalone_toolchain.py \
--arch arm \
--api 9 \
--install-dir=$LIBXML2_TOOLCHAIN_PATH
FF_SYSROOT=$LIBXML2_TOOLCHAIN_PATH/sysroot
# Add the standalone toolchain to the search path.
export PATH=$LIBXML2_TOOLCHAIN_PATH/bin:$PATH
# Tell configure what tools to use.
target_host=arm-linux-androideabi
export AR=$LIBXML2_TOOLCHAIN_PATH/bin/$target_host-ar
export AS=$LIBXML2_TOOLCHAIN_PATH/bin/$target_host-as
export CC=$LIBXML2_TOOLCHAIN_PATH/bin/$target_host-clang
export CXX=$LIBXML2_TOOLCHAIN_PATH/bin/$target_host-clang++
export LD=$$LIBXML2_TOOLCHAIN_PATH/bin/target_host-ld
export STRIP=$LIBXML2_TOOLCHAIN_PATH/bin/$target_host-strip
export RANLIB=$LIBXML2_TOOLCHAIN_PATH/bin/$target_host-ranlib
export LIBS=-ldl
# Tell configure what flags Android requires.
export CFLAGS="-fPIE -fPIC"
export LDFLAGS="-pie"
./autogen.sh --host=arm-linux-androideabi --target=arm-linux-androideabi --with-pic --disable-shared --without-iconv --without-http --without-ftp --without-legacy --without-c14n --without-catalog --without-html --without-writer --without-schematron --without-docbook --without-output --without-push --without-modules --without-tree --without-xptr --without-xinclude --without-xpath --without-schemas --without-sax1 --without-iso8859x --without-python --without-zlib --without-lzma CFLAGS=-DLIBXML_TREE_ENABLED --prefix=/mnt/d/tools/linux/libxml2/../build/libxml2-armv7a/output
make
make install
5.执行编译
6.获取编译结果:lib和include
可以通过修改--prefix的值来修改编译后的lib和include的存放路径