init.sh
#!/bin/bash
NDK=/opt/android_studio/sdk/ndk/22.1.7171670
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
export TARGET=aarch64-linux-android
#export TARGET=armv7a-linux-androideabi
#export TARGET=i686-linux-android
#export TARGET=x86_64-linux-android
export API=29
export AR=$TOOLCHAIN/bin/$TARGET-ar
export AS=$TOOLCHAIN/bin/$TARGET-as
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
export LD=$TOOLCHAIN/bin/$TARGET-ld
export RANLIB=$TOOLCHAIN/bin/$TARGET-ranlib
export STRIP=$TOOLCHAIN/bin/$TARGET-strip
export LD_LIBRARY_PATH=$TOOLCHAIN/sysroot/usr/lib/x86_64-linux-android/:$LD_LIBRARY_PATH
Useage:
$ source init.sh
$CC hello.c -o hello
cmake to compile Android
ref:Use the NDK with other build systems
沒有留言:
張貼留言