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