前言
在编译之前建议先去了解交叉编辑环境生成教程,后续编译基于此。
自定义NDK交叉编译链(toolchain)
环境
操作系统:mac os 10.14.2
ndk版本:android-ndk-r20
libx264: x264-snapshot-20191211-2245
脚本
- 下载x264
- 进入下载后的x264目录,创建build_android.sh
#!/bin/sh
NDK_HOME=~/Library/Android/sdk/ndk-bundle
#自定义NDK toolchain目录
CHAIN_ENV=${NDK_HOME}/Chain/android-toolchain
#ARCH=arm64
ANDROID_ARCH=arm
# All the built binaries, libs and their header will be installed here
PREFIX=~
# static or share libs dir
OUT_PUT=${PREFIX}/android-output
# The cross-compile toolchain we use
TOOLCHAIN=${ANDROID_ARCH}-linux-androideabi
# The path of standalone NDK toolchain
# Refer to https://developer.android.com/ndk/guides/standalone_toolchain.html
NDK_TOOLCHAIN=${CHAIN_ENV}/${ANDROID_ARCH}
# Set Android Sysroot according to API and arch
SYSROOT=${NDK_TOOLCHAIN}/sysroot
ARM_LIB=$SYSROOT/usr/lib
# Binutils path
CROSS_PREFIX=${NDK_TOOLCHAIN}/bin/${TOOLCHAIN}
./configure \
--prefix=${OUT_PUT}/libx264/${ANDROID_ARCH} \
--cross-prefix=${CROSS_PREFIX}- \
--sysroot=$SYSROOT \
--enable-static \
--enable-pic \
--disable-asm \
--host=arm-linux \
make clean
make install
- 添加执行权相执行脚本