Android NDK
Software development kit
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.
Overview
Native libraries can be called from Java code running under the Android Runtime using System.loadLibrary, part of the standard Android Java classes.
Command-line tools can be compiled with the NDK and installed using adb.
Android uses Bionic as its C library, and the LLVM libc++ as its C++ Standard Library. The NDK also includes a variety of other APIs: zlib compression, OpenGL ES or Vulkan graphics, OpenSL ES audio, and various Android-specific APIs for things like logging, access to cameras, or accelerating neural networks.
The NDK includes support for CMake and its own ndk-build (based on GNU Make). Android Studio supports running either of these from Gradle. Other third-party tools allow integrating the NDK into Eclipse and Visual Studio.
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.
Adapted from the Wikipedia article, CC BY-SA 4.0. Continue on Wikipedia
Go deeper
Ideas this article links to.
- LLVMCompiler backend for multiple programming languages
- Repository (version control)Metadata storage for software revision control
- Profiling (computer programming)Measuring the time or resources used by a section of a computer program
- GNU Compiler CollectionFree and open-source compiler for various programming languages
- CompilerSoftware that translates code from one programming language to another