• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Building for Android
2
3Assuming the Android Ndk is installed at location `/path/to/toolchain`, building
4libsndfile for Android (arm-linux-androideabi) should be as simple as:
5```
6autoreconf -vif
7export ANDROID_TOOLCHAIN_HOME=/path/to/android/toolchain
8./Scripts/android-configure.sh
9make
10```
11The `Scripts/android-configure.sh` contains four of variables; `ANDROID_NDK_VER`,
12`ANDROID_GCC_VER`, `ANDROID_API_VER` and `ANDROID_TARGET` that can be overridden
13by setting them before the script is run.
14
15Since I (erikd), do almost zero Android development, I am happy accept patches
16for this documentation and script to improve its utility for real Android
17developers.
18
19---
20
21## Using CMake
22
23(Tested on Linux)
24
25For convenience, export the following variables:
26
27```
28export ANDROID_ABI=arm64-v8a
29export ANDROID_PLATFORM_API_LEVEL=29
30export NDK_ROOT=/path/to/android/ndk
31```
32
33Set `ANDROID_ABI`,  `ANDROID_PLATFORM_API_LEVEL`  according to your target system. Now cd into the libsndfile root directory, and run
34
35```
36cmake -S . -B build  -DCMAKE_TOOLCHAIN_FILE=$NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_ABI=$ANDROID_ABI -DANDROID_PLATFORM=$ANDROID_PLATFORM_API_LEVEL
37```
38
39cd into `build` and run make
40
41```
42cd build
43make [-j <number of parallel jobs>]
44```
45
46This will build libsndfile for android.
47