1# Getting Started with the NDK
2
3The Native Development Kit (NDK) is a toolset that allows you to use C and C++ code with OpenHarmony. As a subset of OpenHarmony 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 OpenHarmony, 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.
4
5
6You can use Node-API in the NDK to access, create, and operate JS objects, and use native dynamic libraries in JS objects.
7
8
9## Use Scenarios
10
11The NDK can be helpful for the cases in which you need to:
12
13- Increase performance in compute-intensive cases, such as games or physical simulations.
14
15- Reuse existing C or C++ libraries.
16
17- Customize a library based on CPU features, for example, performing Neon acceleration.
18
19You are not advised to use the NDK to develop the following:
20
21- C or C++ applications
22
23- Applications that can run on a wide variety of OpenHarmony devices
24
25
26## NDK Basics
27
28Before getting started, familiarity with the following basics is helpful.
29
30
31### Basic NDK Concepts
32
33- **[Node-API](napi-introduction.md)**
34
35  Node-API, formerly called NAPI, is a set of interfaces provided for you to use C and C++ code with OpenHarmony ArkTS/JS. It is a part of NDK interfaces. Although extended from Node-API provided by Node.js, OpenHarmony Node-API is not fully compatible with it.
36
37- **C API**
38
39  C API is a former name of OpenHarmony NDK and is no longer used.
40
41
42### Preparatory Knowledge
43
44- Linux C programming knowledge
45  The kernel and libc are extended based on standards such as POSIX. Mastering basic Linux C programming knowledge can help you better understand OpenHarmony development with the NDK.
46
47- CMake
48  CMake is the default build system of OpenHarmony. For details about how to use CMake, see [CMake Tutorial](https://cmake.org/cmake/help/v3.16/guide/tutorial/).
49
50- Node addons
51  ArkTS uses Node-API as the cross-language invoking interface. Familiarity with the basic [node addons](https://nodejs.org/api/addons.html) helps you better understand how to use Node-API in the NDK.
52
53- Clang/LLVM
54  Basic knowledge of the Clang or LLVM compiler helps you compile better native dynamic libraries.
55
56
57### NDK Directory Structure
58
59- **build** folder: contains the predefined toolchain script **ohos.toolchain.cmake**.
60
61  ![](figures/en_image_0000001770128125.png)
62
63  During compilation, CMake locates the file through **CMAKE_TOOLCHAIN_FILE** and reads the default values in this file, such as the compiler architecture and C++ library link mode.
64
65- **build-tools** folder: contains the build tools provided by the NDK.
66  ```
67  # Check the CMake version.
68  cmake -version
69  # The version information is displayed.
70  cmake version 3.16.5
71  CMake suite maintained and supported by Kitware (kitware.com/cmake).
72  ```
73
74- **llvm** folder: contains the compilers provided by the NDK.
75
76  ![en_image_0000001696408864](figures/en_image_0000001696408864.png)
77
78
79## Common NDK Modules
80
81The following table describes the common modules of the NDK.
82
83
84| Module| Description|
85| -------- | -------- |
86| C standard library| Provides C standard library interfaces based on musl.|
87| C++ standard library| Provides libc++_shared, a C++ runtime library.|
88| Log| Prints logs to the HiLog interface of the system.|
89| Node-API | Acts as an intermediary between ArkTS/JS and C/C++.|
90| libuv | Provides a third-party asynchronous I/O library.|
91| zlib | Provides basic data compression and decompression interfaces.|
92| Rawfile | Provides interfaces for reading various packaged resources of an application.|
93| XComponent | Provides surface and touchscreen event interfaces for you to develop high-performance graphics applications.|
94| Drawing | Provides a 2D graphics library for drawing on the surface.|
95| OpenGL | Provides OpenGL 3D graphics interfaces.|
96| OpenSL ES | Provides interfaces for 2D and 3D audio acceleration.|
97