summaryrefslogtreecommitdiff
path: root/docs/nnfw/howto/CrossBuildForAndroid.md
blob: d7e48c89a5590a5734fda6909fa7c6696b38b56b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Cross building for Android

**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.**

Supported Architecture : AARCH64 only (ARM32 is not supported yet)

## Prepare Android NDK

Use `tools/cross/install_android_ndk.sh` script to prepare Android NDK. This is recommended way to build Android NDK.
You may download it yourself from the offical Android NDK website, but the script does a little more than just downloading and unzipping.

## Build

### Host Environment Requirements

With Ubuntu 16.04, everything is fine except one. CMake 3.6.0 or later is required for Android NDK CMake support.
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.

```bash
docker build --network host -t nnas1804 -f infra/docker/Dockerfile.1804 infra/docker
```

### Get prebuilt ARM Compute Library

Download prebuilt binary from [github](https://github.com/ARM-software/ComputeLibrary/releases). Check the version we support and platform(Android).

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`.

```
libarm_compute_core.so
libarm_compute_graph.so
libarm_compute.so
```

### Build and install the runtime

Some tools/libs are still not supported and those are not built by default - mostly due to dependency on Boost library.
Please refer to `infra/nnfw/cmake/options/options_aarch64-android.cmake` for details.

Different from cross build for linux,

- `NDK_DIR` is required

Here is an example of using Makefile.

```bash
cp -n Makefile.template Makefile

TARGET_OS=android \
CROSS_BUILD=1 \
NDK_DIR=/path/android-tools/r20/ndk \
EXT_ACL_FOLDER=/path/arm_compute-v19.11.1-bin-android/lib/android-arm64-v8a-neon-cl \
make install
```