This information isn’t directly for SDL, but will help you along with
Android-CMake. First off, I forked the OpenCV Android-CMake chain and
made a bunch of fixes/enhancements. I hope other people will
collaborate with me to continue to improve the tool chain. There are a
lot of things I would like to see improved, like not requiring the
standalone toolchain and being able to build multiple architectures
I am successfully using Android-CMake with the NDK r9b. I have built
multiple projects with it: ALmixer, Chipmunk2D, Box2D, and
the code base is so complex and despite some claims, I’m skeptical
anybody has actually gotten it to work on Android because some code
had to be ported just for Android. It’s taken me several weeks and I’m
just starting getting the unit tests running.)
I have a sample repository for an Android Hello World program that
uses ALmixer. ALmixer uses CMake to build. I use my own fork of
Android-CMake which contains fixes to use
the latest NDKs, as well as handle multiple architectures (arm, armv7,
x86). (And I actually got to test on an Samsung x86 based tablet that
the x86 stuff actually worked; they had bugs and the standard #3434
latency in their audio system, but the binary was fine.)
(Note that this example compiles ALmixer without SDL dependencies and
instead uses a new experimental native Android OpenSL ES decoder
backend my team and I have been working on so it won’t directly show
you how to deal with SDL. Side rant: They screwed up their API and
they lack traditional fopen/fread/fseek/fclose function pointer
abstractions found in most C libraries so things like SDL_RWops can’t
be implemented for their audio decoders. Argh! Android!!!)
Additionally, OpenAL-Soft is a dependency that ALmixer depends on,
though this uses its own supplied Makefile system. This is actually a
good example of how to get CMake to find 3rd party dependencies on
Once these components are built as dynamic libraries, the final Hello
World app build process relies on the official NDK external module system to
find ALmixer and OpenAL and build appropriately.
Because there are a lot of disjoint steps, all of this is strung
together by some Perl scripts.
The README.txt contains a lot of information on how to setup things.
Android NDK development is really painful so take your time on this.
Don’t expect to be able to grasp everything in 10 minutes. That said,
I think this example is one of the smoothest examples ever made of
building and using complicated 3rd party dependencies on Android with
The repository can be found at:
EricOn 12/17/13, piperoman <mrpiperoman.hot at gmail.com> wrote:
I need to use SDL in android platform. I usually compile my projects using
CMake, and android toolchain when I need to develop in Android.
I have try to compile the always painful Android.mk, following the
README-android.txt for complext project, but with android-ndk-9b, it
Reading README-cmake.txt, I can read that it cannot be used in Android/iOS
platform. Anyway, I have try to compile it, but it doent work, of course,
the code sources that try to use is not the same that use in Android.mk
My question is, In the future, the CMake is going to support Android & iOS
Platforms? I consider that is the best option for people who work with
I have some experience working with crossplatform projects, using
when is needed, and I took a look into OpenCV cmakes that can teach a lot
crosscompiling. If is needed I can help with that, because its a very
Anyway, someone know where could I find some precompiled SDL and SDL_image
libraries for Android and iOS? I can use the sample project to add the JNI
calls into my projects, but I cannot compile myself the SDL library.
Thanks for your time.
Beginning iPhone Games Development