Imported Upstream version 1.8.0
[platform/core/ml/nnfw.git] / docs / nnfw / howto / CrossBuildForAndroid.md
1 # Cross building for Android
2
3 **Note: To set up a basic build environment on your development PC, please read the [howto.md](../howto.md) document first. The cross build covered in this document assumes that you have an environment in which the native build operates normally without problems.**
4
5 Supported Architecture : AARCH64 only (ARM32 is not supported yet)
6
7 ## Prepare Android NDK
8
9 Use `tools/cross/install_android_ndk.sh` script to prepare Android NDK. This is recommended way to build Android NDK.
10 You may download it yourself from the offical Android NDK website, but the script does a little more than just downloading and unzipping.
11
12 ## Build
13
14 ### Host Environment Requirements
15
16 With Ubuntu 16.04, everything is fine except one. CMake 3.6.0 or later is required for Android NDK CMake support.
17 So if you want to use Docker, please use `infra/docker/Dockerfile.1804` which is based on Ubuntu 18.04. It has CMake 3.10.2.
18
19 ```bash
20 docker build --network host -t nnas1804 -f infra/docker/Dockerfile.1804 infra/docker
21 ```
22
23 ### Get prebuilt ARM Compute Library
24
25 Download prebuilt binary from [github](https://github.com/ARM-software/ComputeLibrary/releases). Check the version we support and platform(Android).
26
27 Then extract the tarball to the folder indicated as EXT_ACL_FOLDER in the example below. We will use the following file in `lib/android-arm64-v8a-neon-cl`.
28
29 ```
30 libarm_compute_core.so
31 libarm_compute_graph.so
32 libarm_compute.so
33 ```
34
35 ### Build and install the runtime
36
37 Some tools/libs are still not supported and those are not built by default - mostly due to dependency on Boost library.
38 Please refer to `infra/nnfw/cmake/options/options_aarch64-android.cmake` for details.
39
40 Different from cross build for linux,
41
42 - `NDK_DIR` is required
43
44 Here is an example of using Makefile.
45
46 ```bash
47 TARGET_OS=android \
48 CROSS_BUILD=1 \
49 NDK_DIR=/path/android-tools/r20/ndk \
50 EXT_ACL_FOLDER=/path/arm_compute-v19.11.1-bin-android/lib/android-arm64-v8a-neon-cl \
51 make -f Makefile.template install
52 ```