Cross Build Libevent-2.1.10 for Andriod
Build Environment Prepare
If you wan to build libevent for andriod you shoud do two things. Frist you should get libevent source code, second you need to get NDK build environment.
Get Libevent-2.1.10 Source Code
-
The libevent source web site at:
http://libevent.org/ -
Get libevent sorce code
wget https://github.com/libevent/libevent/releases/download/release-2.1.10-stable/libevent-2.1.10-stable.tar.gz
Get Andriod NDK and Configure Environment Variable.
- NDK cross build tools web site at:
https://developer.android.google.cn/ndk/downloads/index.html - Set NDK Environment Variable
export NDK_HOME=/home/heyongxin/android-ndk-r16b - Openssl and libcrpto Note
if you wan to use libevent_openssl.a, you need to set openssl include path in build scripts. My computer have make and install libevent in defaut path so i don’t need set it.
Writing the Build Scripts
Arm64-v8a and Armeabi-v7a chip arch hvave covered the most device in the market. so we only provide these two arch’s build script.
The Target Device for Arm64-v8a
#!/bin/sh
NDK=/home/heyongxin/android-ndk-r16b
LIBEVENT_TMP_FOLDER=$PWD
LIBEVENT_TARGET_API=android-23
LIBEVENT_GCC_VERSION=4.9
LIBEVENT_OUTPUT_PATH=$PWD/openssl_build
rm -rf $LIBEVENT_OUTPUT_PATH
mkdir -p $LIBEVENT_OUTPUT_PATH
mkdir -p $LIBEVENT_TMP_FOLDER/android-toolchain-aarch64
NDK_MAKE_TOOLCHAIN=$NDK/build/tools/make-standalone-toolchain.sh