源码
SDL使用版本是SDL2-2.0.3(找了许久才找到的SDL2-2.0.3-Android文档类资源-CSDN下载)
NDK版本是android-ndk-r20
编译脚本
在SDL2-2.0.3/build-scripts下新建androidbuildlibs.sh,也可拷贝SDL2-2.0.14/build-scripts下的androidbuildlibs.sh,因为我们只想编译libSDL2,所以需要将APP_MODULES修改为“APP_MODULES="SDL2"”
# Android.mk is in srcdir
srcdir=`dirname $0`/..
srcdir=`cd $srcdir && pwd`
cd $srcdir
echo $srcdir "---------------------"
#
# Create the build directories
#
build=build
buildandroid=$build/android
obj=
lib=
ndk_args=
# Allow an external caller to specify locations.
for arg in $*
do
if [ "${arg:0:8}" == "NDK_OUT=" ]; then
obj=${arg#NDK_OUT=}
elif [ "${arg:0:13}" == "NDK_LIBS_OUT=" ]; then
lib=${arg#NDK_LIBS_OUT=}
else
ndk_args="$ndk_args $arg"
fi
done
if [ -z $obj ]; then
obj=$buildandroid/obj
fi
if [ -z $lib ]; then
lib=$buildandroid/lib
fi
for dir in $build $buildandroid $obj $lib; do
if test -d $dir; then
:
else
mkdir $dir || exit 1
fi
done
# APP_* variables set in the environment here will not be seen by the
# ndk-build makefile segments that use them, e.g., default-application.mk.
# For consistency, pass all values on the command line.
ndk-build \
NDK_PROJECT_PATH=null \
NDK_OUT=$obj \
NDK_LIBS_OUT=$lib \
APP_BUILD_SCRIPT=Android.mk \
APP_ABI="armeabi-v7a arm64-v8a x86 x86_64" \
APP_PLATFORM=android-16 \
APP_MODULES="SDL2" \
$ndk_args
编译
build-scripts/androidbuildlibs.sh
编译成功之后,会在/build/android/lib下生成相应架构的库
|