1e41f4b71Sopenharmony_ci# NDK Project Building Overview
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ciBy default, the OpenHarmony NDK uses CMake as the build system. To simplify your configuration process, the NDK provides the configuration file [ohos.toolchain.cmake](#introduction-to-ohostoolchaincmake) that complies with the OpenHarmony toolchain to predefine CMake variables.
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciYou can build your project with the NDK in the following modes:
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci- Build from source code
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci  To build from source code, you can use:
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci  - [C++ application template provided by DevEco Studio](build-with-ndk-ide.md)
15e41f4b71Sopenharmony_ci  - [CMake from the command line](build-with-ndk-cmake.md)
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci- [Build with prebuilt libraries](build-with-ndk-prebuilts.md)
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ciThis section uses examples to describe how to use the NDK in a native project and how to write a CMake script to build a project with the NDK.
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci## Introduction to ohos.toolchain.cmake
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci**ohos.toolchain.cmake** is the toolchain script provided by the OpenHarmony NDK for CMake. It predefines the build parameters that need to be set for building OpenHarmony applications, such as the target of the cross compilation device and the link mode of C++ runtime libraries. These parameters can be passed in by running CMake commands to change the default compilation and linking behavior. The following table lists the common parameters in this file.
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci| Name| Type| Description|
28e41f4b71Sopenharmony_ci| -------- | -------- | -------- |
29e41f4b71Sopenharmony_ci| OHOS_STL | c++_shared/c++_static | Link mode of libc++.<br> Default value: **c++_shared**<br>Available options are as follows:<br>**c++_shared**: The native library dynamically links **libc++_shared.so**.<br>**c++_static**: The native library links the static library **libc++_static.a**.<br>Because some global variables are involved during C++ runtime, all native libraries must be linked to your application in the same mode.|
30e41f4b71Sopenharmony_ci| OHOS_ARCH | armeabi-v7a/arm64-v8a/x86_64 | Target architecture for native cross compilation. Available options are as follows: **armeabi-v7a**, **arm64-v8a**, and **x86_64**.|
31e41f4b71Sopenharmony_ci| OHOS_PLATFORM | OHOS | Target platform. Currently, only OpenHarmony is supported.|
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ciThe preceding parameters control the cross compilation commands of Clang and generate proper command parameters.
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci- The **--target={arch}-linux-ohos** parameter instructs the compiler to generate binary files that comply with OpenHarmony ABI in the corresponding architecture.
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci- The **--sysroot={ndk_root}/sysroot** parameter notifies the compiler of the location of the OpenHarmony header files.
38