Ubuntu搭建Android架构so库交叉编译环境

目录


前言

需要将一些源码编译成Android可用的架构的so库

一、下载NDK并安装

https://developer.android.google.cn/ndk/downloads/


二、安装NDK

将下载下来的android-ndk-r23b-linux.zip解压在根目录,并配置环境

vi ~/.profile

在末尾出添加并保存

export ANDROID_NDK_ROOT="/home/marico/android-ndk-r23b"

然后再执行source ~/.profile

在终端上输入ndk-build,提示如下图所示,即安装成功。


三、配置交叉编译工具链

在android-ndk-r23b/build/tools目录有生成独立工具链的脚本make-standalone-toolchain.sh

make-standalone-toolchain.sh --install-dir=/tmp/android-toolchain --arch=arm64 --platform=android-29

--install-dir 工具链安装位置

--arch 编译的so库架构

--platform 编译平台

因为我编译的是Android arm64架构的,采用的是默认配置

android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin

配置工具链的环境

vi ~/.profile

在末尾出添加并保存

export TOOLCHAIN_PATH="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin"

然后再执行source ~/.profile

至此,交叉编译环境已经搭建完成。


四、编写交叉编译脚本

相关推荐
范特西林1 天前
实战演练——从零实现一个高性能 Binder 服务
android
范特西林1 天前
代码的生成:AIDL 编译器与 Parcel 的序列化艺术
android
范特西林1 天前
深入内核:Binder 驱动的内存管理与事务调度
android
范特西林1 天前
解剖麻雀:Binder 通信的整体架构全景图
android
范特西林1 天前
破冰之旅:为什么 Android 选择了 Binder?
android
奔跑中的蜗牛6661 天前
一次播放器架构升级:Android 直播间 ANR 下降 60%
android
测试工坊1 天前
Android 视频播放卡顿检测——帧率之外的第二战场
android
Kapaseker1 天前
一杯美式深入理解 data class
android·kotlin
鹏多多1 天前
Flutter使用screenshot进行截屏和截长图以及分享保存的全流程指南
android·前端·flutter
Carson带你学Android1 天前
OpenClaw移动端要来了?Android官宣AI原生支持App Functions
android