NDK compiles SDL
Get ready:
Hardware
a computer, experiment in Lenovo T430 on
a Android device, experiment at Samsung S3/a7
Compilation Environment:
Ubuntu 14.04 (Ant\java and other commands must be supported )
Tool Kit:
NDK:https://dl.google.com/android/ndk/android-ndk32-r10b-linux-x86_64.tar.bz2
SDK:https://dl.google.com/android/adt/adt-bundle-linux-x86_64-20140702.zip
SDL:http://www.libsdl.org/release/SDL2-2.0.3.tar.gz
Steps:
Unzip Sdl:
Tar-xvzfsdl2-2.0.3.tar.gz
cd~/work/study/ffmpeg/sdl2-2.0.3
Unzip NDK,SDK
SDK Path:/opt/adrd-stuff/adt-bundle-linux-x86_64-20130514/sdk
NDK Path:/opt/adrd-stuff/android-ndk-r10b
the compilation process is simple and has the following two ways: (Please read carefully Sdl2-2.0.3/readme-android.txt)
1. Compile An example of SDL directly:
2. define an APK yourself
1. Direct compilation of an example within SDL, two steps:
(1). Configure The two paths in the build-scripts/androidbuild.sh as follows:
#NDKBUILD = ' Whichndk-build '
Ndkbuild= "/opt/adrd-stuff/android-ndk-r10b/ndk-build"
#ANDROID = ' whichandroid '
Android= "/USR/LOCAL/SHARE/ADT-BUNDLE-LINUX-X86_64-20140702/SDK"
(2). Run commands directly
CD build-scripts
./androidbuild.shorg.libsdl.testgles. /test/testgles.c
2. define an APK yourself
cdandroid-project/jni/src/
in the test/testgles.c, write a c file containing the main function yoursourcehere.c
The experiment can be copied directly , executing the following command sequentially:
# # #pwd: android-project/jni/src/
Cp.. /.. /.. /TEST/TESTGLES.C yoursourcehere.c
Cd.. /jni
ln-s/home/zhou/work/study/ffmpeg/sdl2-2.0.3/sdl
/opt/adrd-stuff/android-ndk-r10b/ndk-build
Cd..
Ant Debug
this will be in bin/
Run APK:
ADB install: /sdl2-2.0.3/build/org.libsdl.testgles/bin/org.libsdl.testgles-debug.apk
ADB install: /sdl2-2.0.3/android-project/bin/sdlactivity-debug.apk
At this point you can see a rotating colored square, as follows
Problems encountered:
NDK version:
32bits for small machine:android-ndk32-r10b-linux-x86_64.tar.bz2
64bits for small machine:android-ndk64-r10b-linux-x86_64.tar.bz2
64bits compiled APK on the S3 run, there will be a flashback phenomenon,
Logcat tips are as follows:
E/DALVIKVM (15444):d lopen ("/data/app-lib/org.libsdl.app-1/libsdl2.so") Failed:dlopen Failed:cannot Locate symbol " Signal "referenced by" libsdl2.so "...
W/DALVIKVM (15444): Exception ljava/lang/unsatisfiedlinkerror; Thrown while initializinglorg/libsdl/app/sdlactivity;
W/DALVIKVM (15444): Class Init failed in newinstance call (lorg/libsdl/app/sdlactivity;)
E/androidruntime (15444):P Rocess:org.libsdl.app, pid:15444
E/androidruntime (15444): at Org.libsdl.app.sdlactivity.<clinit> (sdlactivity.java:49)
W/activitymanager (837): Force finishing Activity org.libsdl.app/. Sdlactivity
NDK compiles SDL