目录

About This Kit

The Native Development Kit (NDK) is a toolset that allows you to use C and C++ code with HarmonyOS. As a subset of HarmonyOS SDK, it provides native APIs, compile scripts, and compile toolchain to help you implement key application features using C or C++. The NDK covers only some basic underlying capabilities of HarmonyOS, such as the C runtime libc, graphics library, window system, multimedia, compression library, and Node-API that bridges ArkTS/JS and C code. It does not provide complete capabilities of ArkTS/JS APIs.

You can use Node-API in the NDK to access, create, and operate JS objects, and use native dynamic libraries in JS objects.

Use Scenarios

The NDK can be helpful for the cases in which you need to:

You are not advised to use the NDK to develop the following:

NDK Basics

Before getting started, familiarity with the following basics is helpful.

[h2]Preparatory Knowledge

[h2]NDK Directory Structure

For details about how to obtain the NDK, see NDK development tool directory.

Common NDK Modules

The following table describes the common modules of the NDK and their functionalities.

Module Description
C standard library Provides C standard library APIs based on musl.
C++ standard library Provides the C++ runtime APIs.
Log Provides APIs for outputting HiLog logs to the system.
Node-API Provides APIs for interaction between ArkTS/JS and C/C++.
FFRT Provides a task-based concurrent programming framework.
libuv Provides a third-party asynchronous I/O library.
zlib Provides the zlib library for basic data compression and decompression.
Rawfile Provides APIs for reading various packaged resources of an application.
XComponent Provides surface and touchscreen event APIs for you to develop high-performance graphics applications.
Drawing Provides a 2D graphics library for drawing on the surface.
OpenGL Provides OpenGL 3D graphics interfaces.
OpenSL ES Provides APIs for 2D and 3D audio acceleration.