在 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"
}
Platform | Package | Size (Bytes) | SHA1 Checksum |
---|---|---|---|
Windows 64-bit | android-ndk-r26d-windows.zip | 665022840 | c7ea35ffe916082876611da1a6d5618d15430c29 |
Mac | android-ndk-r26d-darwin.dmg | 1655224062 | 703100c3d721b04e09f02f3fddc5f1f5ced28b10 |
Linux 64-bit (x86) | android-ndk-r26d-linux.zip | 668556491 | fcdad75a765a46a9cf6560353f480db251d14765 |
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
- 下载并解压
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$
- 为当前用户永久配置环境变量
~/.bashrc
(base) yongqiang@yongqiang:~$ vim ~/.bashrc
...
export NDKROOT=/home/yongqiang/software/android-ndk-r26d
export PATH=${NDKROOT}:${PATH}
...
(base) yongqiang@yongqiang:~$ source ~/.bashrc
- 为所有用户永久配置环境变量
/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
- 验证 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整合第三方技术 …… 中文文档: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中配置,参考这位大佬的笔记 添加链接描述 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 概念:Ajax是一种Web开发技术,允许在不重新加载整个页面的情况下,与服务器交换数据并更新网页的部分内容。 作用: 数据交换:Ajax允许通过JavaScript向服务器发送请求,并能够接收服务器响应的数据。 异…...

面试官:前端实现图片懒加载怎么做?这不是撞我怀里了嘛!
前端懒加载(也称为延迟加载或按需加载)是一种网页性能优化的技术,主要用于在网页中延迟加载某些资源,如图片、视频或其他媒体文件,直到它们实际需要被用户查看或交互时才进行加载。这种技术特别适用于长页面或包含大量…...
每天学习一个Windows命令或Linux命令——seq
今天我们来学习 seq命令! seq命令(单词sequence序列的缩写)是Linux系统中用于输出序列化的一串整数的命令。 一、seq用法 seq用法一共有以下三种: seq [选项]... 尾数 seq [选项]... 首数 尾数 seq [选项]... 首数 增量&#…...

C++设计模式-中介者模式,游戏对象之间的碰撞检测
运行在VS2022,x86,Debug下。 31. 中介者模式 中介者模式允许对象之间通过一个中介者对象进行交互,而不是直接相互引用。可以减少对象之间的直接耦合,同时集中化管理复杂的交互。应用:如在游戏开发中,可以使…...

Rust-02-变量与可变性
在Rust中,变量和可变性是两个重要的概念。 变量:变量是用于存储数据的标识符。在Rust中,变量需要声明其类型,例如: let x: i32 5; // 声明一个名为x的变量,类型为i32(整数)&#…...
mov指令中不允许的操作——汇编语言
在 x86 汇编语言中,MOV 指令的限制有助于确保系统的稳定性和正确的操作。下面详细解释为什么这些操作是不允许的。 1. 段寄存器之间直接传送数据 MOV DS, ES ; 错误,不允许原因: 段寄存器是用来定义程序段的开始位置,如代码段…...

Python进阶-部署Flask项目(以TensorFlow图像识别项目WSGI方式启动为例)
本文详细介绍了如何通过WSGI方式部署一个基于TensorFlow图像识别的Flask项目。首先简要介绍了Flask框架的基本概念及其特点,其次详细阐述了Flask项目的部署流程,涵盖了服务器环境配置、Flask应用的创建与测试、WSGI服务器的安装与配置等内容。本文旨在帮…...
WooYun-2016-199433 -phpmyadmin-反序列化RCE-getshell
参考资料: Phpmyadmin 脚本/设置.php反序列化漏洞 (WooYun-2016-199433)复现_phpmyadmin scriptssetup.php 反序列化漏洞-CSDN博客 https://blog.csdn.net/haoxue__/article/details/129368455利用pearcmd.php文件包含拿shell(L…...

社交“学习伙伴”:Meta Llama助力对话升级
每周跟踪AI热点新闻动向和震撼发展 想要探索生成式人工智能的前沿进展吗?订阅我们的简报,深入解析最新的技术突破、实际应用案例和未来的趋势。与全球数同行一同,从行业内部的深度分析和实用指南中受益。不要错过这个机会,成为AI领…...

LabVIEW 反向工程的实现与法律地位
什么是LabVIEW反向工程? 反向工程是指从现有的应用程序或软件中推导出其设计、架构、代码等信息的过程。对于LabVIEW而言,反向工程涉及从现有的VI(虚拟仪器)文件、项目或应用程序中提取出设计思路、功能模块、算法实现等。 LabV…...
Python怎么做单元测试
在Python中,最常用的单元测试框架是unittest。以下是如何使用unittest进行单元测试的步骤: 导入unittest模块: 首先,你需要导入unittest模块。 import unittest创建测试类: 你需要创建一个继承自unittest.TestCase的类…...
ghidra
https://github.com/NationalSecurityAgency/ghidra ghidra是一个so的逆向工具,功能和jadx-gui类似,但是和jadx-gui专注于java层的不同,ghidra专注于native层的代码反编译(从二进制到c语言)。 一、 安装 准备好java1…...

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

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

C++ MPI多进程并发
下载 用法 mpiexec -n 8 $PROCESS_COUNT x64\Debug\$TARGET.exe 多进程并发启动 mpiexec -f hosts.txt -n 3 $PROCESS_COUNT x64\Debug\$TARGET.exe 联机并发进程,其它联机电脑需在相同路径下有所有程序 //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…...
在软件开发中正确使用MySQL日期时间类型的深度解析
在日常软件开发场景中,时间信息的存储是底层且核心的需求。从金融交易的精确记账时间、用户操作的行为日志,到供应链系统的物流节点时间戳,时间数据的准确性直接决定业务逻辑的可靠性。MySQL作为主流关系型数据库,其日期时间类型的…...

Prompt Tuning、P-Tuning、Prefix Tuning的区别
一、Prompt Tuning、P-Tuning、Prefix Tuning的区别 1. Prompt Tuning(提示调优) 核心思想:固定预训练模型参数,仅学习额外的连续提示向量(通常是嵌入层的一部分)。实现方式:在输入文本前添加可训练的连续向量(软提示),模型只更新这些提示参数。优势:参数量少(仅提…...

K8S认证|CKS题库+答案| 11. AppArmor
目录 11. AppArmor 免费获取并激活 CKA_v1.31_模拟系统 题目 开始操作: 1)、切换集群 2)、切换节点 3)、切换到 apparmor 的目录 4)、执行 apparmor 策略模块 5)、修改 pod 文件 6)、…...

【JVM】- 内存结构
引言 JVM:Java Virtual Machine 定义:Java虚拟机,Java二进制字节码的运行环境好处: 一次编写,到处运行自动内存管理,垃圾回收的功能数组下标越界检查(会抛异常,不会覆盖到其他代码…...

376. Wiggle Subsequence
376. Wiggle Subsequence 代码 class Solution { public:int wiggleMaxLength(vector<int>& nums) {int n nums.size();int res 1;int prediff 0;int curdiff 0;for(int i 0;i < n-1;i){curdiff nums[i1] - nums[i];if( (prediff > 0 && curdif…...
Matlab | matlab常用命令总结
常用命令 一、 基础操作与环境二、 矩阵与数组操作(核心)三、 绘图与可视化四、 编程与控制流五、 符号计算 (Symbolic Math Toolbox)六、 文件与数据 I/O七、 常用函数类别重要提示这是一份 MATLAB 常用命令和功能的总结,涵盖了基础操作、矩阵运算、绘图、编程和文件处理等…...

tree 树组件大数据卡顿问题优化
问题背景 项目中有用到树组件用来做文件目录,但是由于这个树组件的节点越来越多,导致页面在滚动这个树组件的时候浏览器就很容易卡死。这种问题基本上都是因为dom节点太多,导致的浏览器卡顿,这里很明显就需要用到虚拟列表的技术&…...
Swagger和OpenApi的前世今生
Swagger与OpenAPI的关系演进是API标准化进程中的重要篇章,二者共同塑造了现代RESTful API的开发范式。 本期就扒一扒其技术演进的关键节点与核心逻辑: 🔄 一、起源与初创期:Swagger的诞生(2010-2014) 核心…...

【开发技术】.Net使用FFmpeg视频特定帧上绘制内容
目录 一、目的 二、解决方案 2.1 什么是FFmpeg 2.2 FFmpeg主要功能 2.3 使用Xabe.FFmpeg调用FFmpeg功能 2.4 使用 FFmpeg 的 drawbox 滤镜来绘制 ROI 三、总结 一、目的 当前市场上有很多目标检测智能识别的相关算法,当前调用一个医疗行业的AI识别算法后返回…...

GitFlow 工作模式(详解)
今天再学项目的过程中遇到使用gitflow模式管理代码,因此进行学习并且发布关于gitflow的一些思考 Git与GitFlow模式 我们在写代码的时候通常会进行网上保存,无论是github还是gittee,都是一种基于git去保存代码的形式,这样保存代码…...