当前位置: 首页 > news >正文

在 Linux 系统上安装 Android NDK

在 Linux 系统上安装 Android NDK

  • 1. Android NDK
  • 2. NDK Downloads
    • 2.1. Latest LTS Version (r26d)
    • 2.2. Old Unsupported Versions
  • 3. 安装 NDK
  • 4. Get started with the NDK (NDK 使用入门)
  • References

1. Android NDK

https://developer.android.com/ndk

The Android NDK is a toolset that lets you implement parts of your app in native code, using languages such as C and C++. For certain types of apps, this can help you reuse code libraries written in those languages.
Android NDK 是一个工具集,可让您以原生代码 (using languages such as C and C++) 实现应用的各个部分。对于特定类型的应用,这可以帮助您重复使用以这些语言编写的代码库。

The Android Native Development Kit (NDK) provides a cross-compiling tool for compiling code written in C/C++ can be compiled to ARM, or x86 native code (or their 64-bit variants) for Android. The NDK uses the Clang compiler to compile C/C++. GCC was included until NDK r17, but removed in r18 in 2018.

The NDK includes support for CMake and its own ndk-build (based on GNU Make). For CPU profiling, the NDK also includes simpleperf which is similar to the Linux perf tool, but with better support for Android and specifically for mixed Java/C++ stacks.

2. NDK Downloads

https://developer.android.com/ndk/downloads

https://github.com/android/ndk/wiki

Select the NDK package for your development platform. In most cases it will be easier to use the Android SDK manager to install the NDK.

2.1. Latest LTS Version (r26d)

android {ndkVersion "26.3.11579264"
}
PlatformPackageSize (Bytes)SHA1 Checksum
Windows 64-bitandroid-ndk-r26d-windows.zip665022840c7ea35ffe916082876611da1a6d5618d15430c29
Macandroid-ndk-r26d-darwin.dmg1655224062703100c3d721b04e09f02f3fddc5f1f5ced28b10
Linux 64-bit (x86)android-ndk-r26d-linux.zip668556491fcdad75a765a46a9cf6560353f480db251d14765
https://dl.google.com/android/repository/android-ndk-r26d-linux.zip

2.2. Old Unsupported Versions

https://github.com/android/ndk/wiki/Unsupported-Downloads

Note: these obsolete versions of the NDK are no longer supported.

r25c

https://dl.google.com/android/repository/android-ndk-r25c-linux.zip

r24

https://dl.google.com/android/repository/android-ndk-r24-linux.zip

r23c

https://dl.google.com/android/repository/android-ndk-r23c-linux.zip

r22b

https://dl.google.com/android/repository/android-ndk-r22b-linux-x86_64.zip

r21e

3. 安装 NDK

https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip
  1. 下载并解压 android-ndk-r26d-linux.zip

wget https://dl.google.com/android/repository/android-ndk-r26d-linux.zip --no-check-certificate

(base) yongqiang@yongqiang:~/software$ wget https://dl.google.com/android/repository/android-ndk-r26d-linux.zip
(base) yongqiang@yongqiang:~/software$ chmod a+x android-ndk-r26d-linux.zip
(base) yongqiang@yongqiang:~/software$ unzip android-ndk-r26d-linux.zip
(base) yongqiang@yongqiang:~/software$ rm -rf android-ndk-r26d-linux.zip
(base) yongqiang@yongqiang:~/software$ cd android-ndk-r26d/
(base) yongqiang@yongqiang:~/software/android-ndk-r26d$ pwd
/home/yongqiang/software/android-ndk-r26d
(base) yongqiang@yongqiang:~/software/android-ndk-r26d$
  1. 为当前用户永久配置环境变量

~/.bashrc

(base) yongqiang@yongqiang:~$ vim ~/.bashrc
...
export NDKROOT=/home/yongqiang/software/android-ndk-r26d
export PATH=${NDKROOT}:${PATH}
...
(base) yongqiang@yongqiang:~$ source ~/.bashrc
  1. 为所有用户永久配置环境变量

/etc/profile

(base) yongqiang@yongqiang:~$ vim /etc/profile
...
export NDKROOT=/home/yongqiang/software/android-ndk-r26d
export PATH=${NDKROOT}:${PATH}
...
(base) yongqiang@yongqiang:~$ source /etc/profile
  1. 验证 NDK 安装

ndk-build -v

(base) yongqiang@yongqiang:~$ ndk-build -v
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
(base) yongqiang@yongqiang:~$
(base) yongqiang@yongqiang:~$ echo ${PATH}
/home/yongqiang/software/android-ndk-r26d:/home/yongqiang/vulkan/1.3.239.0/x86_64/bin:/home/yongqiang/miniconda3/bin:/home/yongqiang/miniconda3/condabin:/home/yongqiang/vulkan/1.3.239.0/x86_64/bin:
...

4. Get started with the NDK (NDK 使用入门)

https://developer.android.com/ndk/guides

The Native Development Kit (NDK) is a set of tools that allows you to use C and C++ code with Android, and provides platform libraries you can use to manage native activities and access physical device components, such as sensors and touch input. The NDK may not be appropriate for most novice Android programmers who need to use only Java code and framework APIs to develop their apps.
Native Development Kit (NDK) 是一套工具,使你能够在 Android 应用中使用 C 和 C++ 代码,并提供众多平台库,你可使用这些平台库管理原生 activity 和访问实体设备组件,例如传感器和触控输入。NDK 可能不适合大多数 Android 编程初学者,这些初学者只需使用 Java 代码和框架 API 开发应用。

However, the NDK can be useful for cases in which you need to do one or more of the following:

  • Squeeze extra performance out of a device to achieve low latency or run computationally intensive applications, such as games or physics simulations.
    进一步提升设备性能,以降低延迟或运行游戏或物理模拟等计算密集型应用。
  • Reuse your own or other developers’ C or C++ libraries.
    重复使用你自己或其他开发者的 C 或 C++ 库。

Using Android Studio 2.2 and higher, you can use the NDK to compile C and C++ code into a native library and package it into your APK using Gradle, the IDE’s integrated build system. Your Java code can then call functions in your native library through the Java Native Interface (JNI) framework.
你可以在 Android Studio 2.2 或更高版本中使用 NDK 将 C 和 C++ 代码编译到原生库中,然后使用 Android Studio 的集成构建系统 Gradle 将原生库打包到 APK 中。Java 代码随后可以通过 Java 原生接口 (JNI) 框架调用原生库中的函数。

Android Studio’s default build tool to compile native libraries is CMake. Android Studio also supports ndk-build due to the large number of existing projects that use the build toolkit. However, if you are creating a new native library, you should use CMake.
Android Studio 编译原生库的默认构建工具是 CMake。由于很多现有项目都使用 ndk-build 构建工具包,因此 Android Studio 也支持 ndk-build。不过,如果您要创建新的原生库,则应使用 CMake。

The Android Native Development Kit (NDK): a set of tools that allows you to use C and C++ code with Android.
这套工具使您能在 Android 应用中使用 C 和 C++ 代码。

CMake: an external build tool that works alongside Gradle to build your native library. You do not need this component if you only plan to use ndk-build.
如果你只计划使用 ndk-build,则不需要此组件。

LLDB: the debugger Android Studio uses to debug native code.
Android Studio 用于调试原生代码的调试程序。

References

[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/

相关文章:

在 Linux 系统上安装 Android NDK

在 Linux 系统上安装 Android NDK 1. Android NDK2. NDK Downloads2.1. Latest LTS Version (r26d)2.2. Old Unsupported Versions 3. 安装 NDK4. Get started with the NDK (NDK 使用入门)References 1. Android NDK https://developer.android.com/ndk The Android NDK is …...

SpringBoot的学习要点

目录 SpringBoot 创建项目 配置文件 注解 命名规范 SpringBoot整合第三方技术 …… 中文文档&#xff1a;Spring Boot 中文文档 SpringBoot Spring Boot 是基于 Spring 框架的一种快速构建微服务应用的方式它主要提供了自动配置、简化配置、运行时应用监控等功能它…...

vue3引入cesium和olcs

首先引入包 pnpm i olcs; pnpm i -D vite-plugin-cesium pnpm i -S cesium在vite.config.js中配置&#xff0c;参考这位大佬的笔记 添加链接描述 import { defineConfig } from vite import vue from vitejs/plugin-vue import cesium from vite-plugin-cesium; // https://…...

代码随想录算法训练营第25天|回溯

回溯part02 216. 组合总和 III /*** param {number} k* param {number} n* return {number[][]}*/ var combinationSum3 function(k, n) {// k个数字相加为n// 只能使用1-9// 每个数字只能使用一次// 不能重复 如 1 2 4 、 4 1 2 不可以let res [];backtracking(k, n, [], …...

Ajax 快速入门

Ajax 概念&#xff1a;Ajax是一种Web开发技术&#xff0c;允许在不重新加载整个页面的情况下&#xff0c;与服务器交换数据并更新网页的部分内容。 作用&#xff1a; 数据交换&#xff1a;Ajax允许通过JavaScript向服务器发送请求&#xff0c;并能够接收服务器响应的数据。 异…...

面试官:前端实现图片懒加载怎么做?这不是撞我怀里了嘛!

前端懒加载&#xff08;也称为延迟加载或按需加载&#xff09;是一种网页性能优化的技术&#xff0c;主要用于在网页中延迟加载某些资源&#xff0c;如图片、视频或其他媒体文件&#xff0c;直到它们实际需要被用户查看或交互时才进行加载。这种技术特别适用于长页面或包含大量…...

每天学习一个Windows命令或Linux命令——seq

今天我们来学习 seq命令&#xff01; seq命令&#xff08;单词sequence序列的缩写&#xff09;是Linux系统中用于输出序列化的一串整数的命令。 一、seq用法 seq用法一共有以下三种&#xff1a; seq [选项]... 尾数 seq [选项]... 首数 尾数 seq [选项]... 首数 增量&#…...

C++设计模式-中介者模式,游戏对象之间的碰撞检测

运行在VS2022&#xff0c;x86&#xff0c;Debug下。 31. 中介者模式 中介者模式允许对象之间通过一个中介者对象进行交互&#xff0c;而不是直接相互引用。可以减少对象之间的直接耦合&#xff0c;同时集中化管理复杂的交互。应用&#xff1a;如在游戏开发中&#xff0c;可以使…...

Rust-02-变量与可变性

在Rust中&#xff0c;变量和可变性是两个重要的概念。 变量&#xff1a;变量是用于存储数据的标识符。在Rust中&#xff0c;变量需要声明其类型&#xff0c;例如&#xff1a; let x: i32 5; // 声明一个名为x的变量&#xff0c;类型为i32&#xff08;整数&#xff09;&#…...

mov指令中不允许的操作——汇编语言

在 x86 汇编语言中&#xff0c;MOV 指令的限制有助于确保系统的稳定性和正确的操作。下面详细解释为什么这些操作是不允许的。 1. 段寄存器之间直接传送数据 MOV DS, ES ; 错误&#xff0c;不允许原因&#xff1a; 段寄存器是用来定义程序段的开始位置&#xff0c;如代码段…...

Python进阶-部署Flask项目(以TensorFlow图像识别项目WSGI方式启动为例)

本文详细介绍了如何通过WSGI方式部署一个基于TensorFlow图像识别的Flask项目。首先简要介绍了Flask框架的基本概念及其特点&#xff0c;其次详细阐述了Flask项目的部署流程&#xff0c;涵盖了服务器环境配置、Flask应用的创建与测试、WSGI服务器的安装与配置等内容。本文旨在帮…...

WooYun-2016-199433 -phpmyadmin-反序列化RCE-getshell

参考资料&#xff1a; Phpmyadmin 脚本/设置.php反序列化漏洞 &#xff08;WooYun-2016-199433&#xff09;复现_phpmyadmin scriptssetup.php 反序列化漏洞-CSDN博客 https://blog.csdn.net/haoxue__/article/details/129368455利用pearcmd.php文件包含拿shell&#xff08;L…...

社交“学习伙伴”:Meta Llama助力对话升级

每周跟踪AI热点新闻动向和震撼发展 想要探索生成式人工智能的前沿进展吗&#xff1f;订阅我们的简报&#xff0c;深入解析最新的技术突破、实际应用案例和未来的趋势。与全球数同行一同&#xff0c;从行业内部的深度分析和实用指南中受益。不要错过这个机会&#xff0c;成为AI领…...

LabVIEW 反向工程的实现与法律地位

什么是LabVIEW反向工程&#xff1f; 反向工程是指从现有的应用程序或软件中推导出其设计、架构、代码等信息的过程。对于LabVIEW而言&#xff0c;反向工程涉及从现有的VI&#xff08;虚拟仪器&#xff09;文件、项目或应用程序中提取出设计思路、功能模块、算法实现等。 LabV…...

Python怎么做单元测试

在Python中&#xff0c;最常用的单元测试框架是unittest。以下是如何使用unittest进行单元测试的步骤&#xff1a; 导入unittest模块&#xff1a; 首先&#xff0c;你需要导入unittest模块。 import unittest创建测试类&#xff1a; 你需要创建一个继承自unittest.TestCase的类…...

ghidra

https://github.com/NationalSecurityAgency/ghidra ghidra是一个so的逆向工具&#xff0c;功能和jadx-gui类似&#xff0c;但是和jadx-gui专注于java层的不同&#xff0c;ghidra专注于native层的代码反编译&#xff08;从二进制到c语言&#xff09;。 一、 安装 准备好java1…...

如何解决网络问题?

组织和 IT 管理员尽其所能完善他们的网络&#xff0c;但是&#xff0c;不同程度的网络问题仍然可能出现&#xff0c;这些网络问题需要立即响应和解决&#xff0c;如果这些问题在不合理的时间内得不到解决&#xff0c;网络和组织的损害可能会付出高昂的代价。这就是为什么 IT 管…...

高速USB转串口芯片CH343

CH343封装 截止目前&#xff0c;主要封装有 SOP16: CH343G QFN16: CH343P ESSOP10: CH343K,截止24年6月未生产 CH343串口速度 最高串口速度&#xff1a; 6Mbps,比CH340的2M&#xff0c;快3倍 1、概述 参考版本&#xff1a;1E CH343 是一个 USB 总线的转接芯片&#xff0c;…...

C++ MPI多进程并发

下载 用法 mpiexec -n 8 $PROCESS_COUNT x64\Debug\$TARGET.exe 多进程并发启动 mpiexec -f hosts.txt -n 3 $PROCESS_COUNT x64\Debug\$TARGET.exe 联机并发进程&#xff0c;其它联机电脑需在相同路径下有所有程序 //hosts.txt 192.168.86.16 192.168.86.123 192.168…...

UFS协议入门-分层结构

写在前面:本文参考UFS jedec3.1,本文思维导图如下 1. 分层概述 UFS协议分为3层,从上至下分别是:应用层(UAP),传输层(UTP),互联层(UIC),具体结构如下图所示。 2.1 应用层 在应用层(UAP)中,包括:UFS指令集(UCS),设备管理器(Device Manager),任务管理器(Task Manager…...

别再只点CubeMX的SDRAM选项了!STM32F429IGT6外扩W9825G6KH内存的完整驱动与读写测试指南

STM32F429IGT6外扩W9825G6KH内存实战&#xff1a;从CubeMX配置到完整驱动开发的深度解析 如果你正在使用STM32F429IGT6开发板&#xff0c;并且需要扩展大容量内存&#xff0c;W9825G6KH-6I这颗32MB的SDRAM芯片可能已经在你的硬件清单上。许多开发者习惯性地依赖STM32CubeMX生成…...

分布式系统智能告警治理:开源AIOps平台技术架构深度解析

分布式系统智能告警治理&#xff1a;开源AIOps平台技术架构深度解析 【免费下载链接】keep The open-source AIOps and alert management platform 项目地址: https://gitcode.com/GitHub_Trending/kee/keep 随着微服务和云原生架构的普及&#xff0c;分布式系统的监控告…...

处理电商分类难题:我是如何用XGBoost为Otto数据集做多类别预测的

电商商品分类实战&#xff1a;XGBoost在Otto数据集上的高阶应用 当面对海量商品需要精准分类时&#xff0c;传统人工规则往往力不从心。Otto Group Product Classification Challenge正是这样一个典型场景——需要将数十万商品准确划分到93个类别中。本文将分享如何用XGBoost构…...

从格式混乱到工作流重构:Cloud Document Converter如何重塑飞书文档迁移体验

从格式混乱到工作流重构&#xff1a;Cloud Document Converter如何重塑飞书文档迁移体验 【免费下载链接】cloud-document-converter Convert Lark Doc to Markdown 项目地址: https://gitcode.com/gh_mirrors/cl/cloud-document-converter 你是否曾花费数小时手动复制飞…...

基于Python与aiogram构建多模型AI助手:集成GPT-4、Claude与Gemini的Telegram机器人开发实践

1. 项目概述&#xff1a;一个多模型AI助手的自研之路 最近在折腾一个挺有意思的玩意儿&#xff0c;我把它叫做“AIAssistantBot”。简单来说&#xff0c;这是一个跑在Telegram上的机器人&#xff0c;但它不是那种只会回复固定指令的“傻”机器人。它的核心是整合了市面上几家主…...

基于LLM与RAG的法律AI工具:从架构解析到工程实践

1. 项目概述&#xff1a;一个法律文本智能生成与分析的AI工具最近在和一些做法律科技的朋友聊天时&#xff0c;他们反复提到一个痛点&#xff1a;处理海量的、格式固定的法律文书&#xff0c;比如起诉状、合同、律师函&#xff0c;既耗时又容易在细节上出错。人工起草一份严谨的…...

ాలుWindows上的安卓应用安装器APK Installer:打破平台壁垒的轻量级解决方案

#ాలుWindows上的安卓应用安装器APK Installer&#xff1a;打破平台壁垒的轻量级解决方案 【免费下载链接】APK-Installer An Android Application Installer for Windows 项目地址: https://gitcode.com/GitHub_Trending/ap/APK-Installer 在数字生态日益多元化的今天…...

终极指南:在Windows上无需模拟器安装安卓应用的完整教程

终极指南&#xff1a;在Windows上无需模拟器安装安卓应用的完整教程 【免费下载链接】APK-Installer An Android Application Installer for Windows 项目地址: https://gitcode.com/GitHub_Trending/ap/APK-Installer 还在为安卓模拟器的臃肿和卡顿烦恼吗&#xff1f;今…...

别再只跟 AI 聊天了,教它干活才是正经事

摘要大模型只会聊天&#xff1f;那你可能用错了方式。函数调用让 AI 从"说"变成"做"&#xff0c;能真正执行任务。本文分享我搭建 AI Agent 的实战经验&#xff0c;包括工具设计、参数校验、错误处理等核心环节&#xff0c;帮你避开那些我踩过的坑。开篇引…...

芯片巨头并购软件公司:从硬件竞赛到软硬协同的产业变革

1. 行业现象背后的深层逻辑最近和几个在芯片设计公司和EDA软件公司工作的老朋友聊天&#xff0c;大家不约而同地提到了一个趋势&#xff1a;芯片巨头们的手&#xff0c;伸得越来越长了。以前是买IP核、买制造厂&#xff0c;现在则是频频出手&#xff0c;将一家家软件公司收入囊…...