搭建工具環境
安裝系統工具
sudo apt-get install autoconf ???point docbook2x tofrodos
下載NDK,android-ndk-r14b-linux-x86_64.zip,解壓後,在NDK目錄執行:
mkdir -p /mnt/work/toolchain/android-standalone-r14b
export ANDROID_HOME=/mnt/work/toolchain/android-standalone-r14b
build/tools/make_standalone_toolchain.py \
--arch arm --api 16 --stl=gnustl \
--install-dir $ANDROID_HOME/toolchain
export ANDROID_NDK_ROOT=/mnt/work/toolchain/ndk/android-ndk-r14b
export ANDROID_NDK_HOME=/mnt/work/toolchain/ndk/android-ndk-r14b
構建依賴庫
c-ares
git clone https://github.com/c-ares/c-ares.git
cd c-ares
git br 1.15.0 e982924acee7f7313b4baa4ee5ec000c5e373c30
git co 1.15.0
./buildconf
./configure \
--prefix=${ANDROID_HOME}/usr/local \
--host=arm-linux-androideabi \
CC=arm-linux-androideabi-gcc \
--enable-shared=no \
--enable-static=yes
make install
cd ..
libexpat
git clone https://github.com/libexpat/libexpat.git
cd libexpat
git br 2.2.6 39e487da353b20bb3a724311d179ba0fddffc65b
git co 2.2.6
./buildconf
./configure \
--prefix=${ANDROID_HOME}/usr/local \
--host=arm-linux-androideabi \
CC=arm-linux-androideabi-gcc \
--enable-shared=no \
--enable-static=yes \
--with-docbook
make install
cd ..
openssl
git clone https://github.com/openssl/openssl.git
cd openssl
git br 1.1.1b 50eaac9f3337667259de725451f201e784599687
git co 1.1.1b
wget https://wiki.openssl.org/images/7/70/Setenv-android.sh
fromdos Setenv-android.sh
chmod u+x Setenv-android.sh
. Setenv-android.sh
./config shared no-ssl2 no-ssl3 no-comp no-hw no-engine \
--openssldir=${ANDROID_HOME}/usr/local \
--prefix=${ANDROID_HOME}/usr/local
make depend
make all
make install \
CC=$ANDROID_TOOLCHAIN/arm-linux-androideabi-gcc \
RANLIB=$ANDROID_TOOLCHAIN/arm-linux-androideabi-ranlib
export PATH=${PATH#*:}
cd ..
zlib
(tar.gz包手動下載)
tar -xzvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
export CC=arm-linux-androideabi-gcc
./configure \
--prefix=${ANDROID_HOME}/usr/local \
-static
make install
libssh2
git clone https://github.com/libssh2/libssh2.git
cd libssh2
# 1.8.2 failed need patch d071e0e07b2, use master
# git br 1.8.2 02ecf17a6d5f9837699e8fb3aad0c804caa67eeb
# git co 1.8.2
./configure \
--prefix=${ANDROID_HOME}/usr/local \
--host=arm-linux-androideabi \
CC=arm-linux-androideabi-gcc \
--enable-shared=no \
--enable-static=yes
make install
構建aria2
git clone https://github.com/aria2/aria2.git
cd aria2
autoreconf -i
./android-config
./android-make
./android-release
ln -s src/.libs/libaria2.a
cd ..
如果要生成動態鏈接庫
/bin/bash ../libtool --silent --tag=CXX --mode=link \
/home/cmguo/work/toolchain/android-standalone-r14b/toolchain/bin/arm-linux-androideabi-clang++ \
-export-dynamic -std=c++11 -pipe -Os -g -fPIE -pie -shared \
-L/home/cmguo/work/toolchain/android-standalone-r14b/usr/local/lib -o libaria2.so main.o libaria2.la \
-L/home/cmguo/work/toolchain/android-standalone-r14b/usr/local/lib -lz \
-L/home/cmguo/work/toolchain/android-standalone-r14b/usr/local/lib -lexpat \
-L/home/cmguo/work/toolchain/android-standalone-r14b/usr/local/lib -lssl -lcrypto \
-L/home/cmguo/work/toolchain/android-standalone-r14b/usr/local/lib -lssh2 \
-L/home/cmguo/work/toolchain/android-standalone-r14b/usr/local/lib -lcares \
../deps/wslay/lib/libwslay.la