1---
2permalink: /trustzone-sdk-docs/building-rust-ca-as-android-elf.md
3---
4
5# Building Rust CA as Android ELF
6
7In Teaclave TrustZone SDK, example CAs are built as ARM64 Linux ELF by default.
8Besides, you can follow these steps to build Rust CAs running on the Android
9platform:
10
111. Download Android NDK toolchain
12
13```
14$ wget https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip
15$ unzip android-ndk-r21e-linux-x86_64.zip
16```
17
182. Add the android target
19
20```
21$ rustup target add aarch64-linux-android
22```
23
243. Set toolchains for the target. Add PATH env:
25
26```
27export PATH=$PATH:/your/path/to/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/
28```
29
304. Edit `incubator-teaclave-trustzone-sdk/.cargo/config`, add:
31
32```
33[target.aarch64-linux-android]
34linker = "aarch64-linux-android28-clang"
35ar = "aarch64-linux-android-ar"
36```
37
385. Copy Android libteec.so to
39`/incubator-teaclave-trustzone-sdk/optee/optee_client/out/export/usr/lib`.
40
41- Note: If you've not built the libteec.so of Android, you can build it using:
42```
43$ cd /path/to/optee/optee_client/
44$ ndk-build APP_BUILD_SCRIPT=./Android.mk NDK_PROJECT_PATH=. NDK_LOG=1 APP_PLATFORM=android-29
45```
46
476. Modify CA's Makefile:
48
49```
50NAME := hello_world-rs
51TARGET := aarch64-linux-android
52OPTEE_DIR ?= ../../../optee
53OUT_DIR := $(CURDIR)/target/$(TARGET)/release
54
55all: host
56
57host:
58        @cargo build --target $(TARGET) --release --verbose
59clean:
60        @cargo clean
61```
62
637. build:
64
65```
66$ make -C examples/hello_world-rs/host
67```
68