此处只给出 NDK 独立工具链的生成方法;
一、下载NDK
墙内下载地址:NDK下载
此时最新稳定版本 (r16b)
二、提取独立编译工具链
-
解压之后得到文件夹:android-ndk-r16b
-
配置NDK环境变量
# 在 /etc/profile 中添加如下语句 export NDK_HOME=[你的路径]/android-ndk-r16b export PATH=$NDK_HOME:$PATH
# 最后使环境变量生效 # source /etc/profile
-
提取
# 使用 NDK 提供的工具提取 $NDK_HOME/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-22 --install-dir=/tmp/android-standalone-toolchain-22 # 参数说明: # --arch:目标系统运行平台 # --platform:对应目标 android 系统的 API # --install-dir:提取后工具链的存储路径(可以随便移动,及时更新环境变量即可)
-
–arch 参数表
工具链 值 mips64 编译器 –arch=mips64 mips GCC 4.8 编译器 –arch=mips x86 GCC 4.8 编译器 –arch=x86 x86_64 GCC 4.8 编译器 –arch=x86_64 arm –arch=arm arm64 –arch=arm64
-
三、添加环境变量并使用
-
添加环境变量
# 添加编译工具链的环境变量 export $ANDROID_TOOLS_HOME=[你的工具链路径] export PATH=$PATH:$ANDROID_TOOLS_HOME/bin
# 最后使环境变量生效 # source /etc/profile
-
使用
root@ubuntu:/work/test/android-tools# arm-linux-androideabi-gcc -v Using built-in specs. ... ... ... Thread model: posix gcc version 4.9.x 20150123 (prerelease) (GCC) root@ubuntu:/work/test/android-tools#
-
至此,所有工作已完成。
—— 2018-12-04 ——