Move android and rpi examples to others

This commit is contained in:
Milan Nikolic 2018-05-06 12:54:20 +02:00
parent 5f11d4eab4
commit 438d1cfad7
16 changed files with 2 additions and 2 deletions

View file

@ -0,0 +1,36 @@
### Android example
To compile example to shared library you will need [Android NDK](https://developer.android.com/ndk/downloads/index.html).
To build Android apk you will need [Android SDK](http://developer.android.com/sdk/index.html#Other).
Export path to Android NDK, point to location where you have unpacked archive:
export ANDROID_NDK_HOME=/opt/android-ndk
Add toolchain bin directory to PATH:
export PATH=${ANDROID_NDK_HOME}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:${PATH}
Export sysroot path:
export ANDROID_SYSROOT=${ANDROID_NDK_HOME}/platforms/android-16/arch-arm
And compile shared library:
CC=arm-linux-androideabi-gcc \
CGO_CFLAGS="-I${ANDROID_SYSROOT}/usr/include --sysroot=${ANDROID_SYSROOT}" \
CGO_LDFLAGS="-L${ANDROID_SYSROOT}/usr/lib --sysroot=${ANDROID_SYSROOT}" \
CGO_ENABLED=1 GOOS=android GOARCH=arm \
go build -buildmode=c-shared -ldflags="-s -w -extldflags=-Wl,-soname,libexample.so" \
-o=android/libs/armeabi-v7a/libexample.so
To build apk export path to Android SDK, point to location where you unpacked archive:
export ANDROID_HOME=/opt/android-sdk
And build apk with ant:
cd android
ant clean debug
If everything is successfully built apk can be found in bin/ directory.