Is it possible to compile SDL as a static or dynamic library for Android,
so I can link it afterwards in different projects?
Currently, I’m trying to cross-compile it with configure
–host=arm-linux-androideabi, but it fails when trying to compile
SDL_x11opengl.c
As Android.mk defines the files to compile, is there a configure set of
flags that compile those precise files?
create a file like android-build/Application.mk:
APP_OPTIM := release
APP_MODULES := libsdl
APP_PLATFORM := android-9
Edit Android.mk to specify a build path (using cwd otherwise):
LOCAL_PATH = /Users/doug/projects/core/deps/sdl/SDL
Then run ndk-build in android-build. It’ll generate output like:
~projects/core/android-build$ ~/projects/libs/android-ndk/ndk-build
Compile thumb : sdl <= SDL.c
Compile thumb : sdl <= SDL_assert.c
Compile thumb : sdl <= SDL_error.c
Compile thumb : sdl <= SDL_fatal.c
Compile thumb : sdl <= SDL_hints.c
…
Compile thumb : sdl <= SDL_androidvideo.c
Compile thumb : sdl <= SDL_androidwindow.c
SharedLibrary : libsdl.so
Install : libsdl.so => libs/armeabi/libsdl.so
That binary: libs/armeabi/libsdl.so is a binary target you can link against
or dlopen from your app.
(You’ll want to customize Application.mk if you want to build for other
platforms)
(Just my $0.02, but configure is broken and useless for
cross compilation like this; even if you create a custom toolchain and try
to invoke it, it’ll still screw up and try to either 1) link the wrong
files or 2) just fall over for no reason. Stay away if you value your
sanity)~
Doug.
On Thu, Jan 10, 2013 at 1:57 AM, ?lvaro Castro-Castilla < alvaro.castro.castilla at gmail.com> wrote:
Currently, I’m trying to cross-compile it with configure
–host=arm-linux-androideabi, but it fails when trying to compile
SDL_x11opengl.c
create a file like android-build/Application.mk:
APP_OPTIM := release
APP_MODULES := libsdl
APP_PLATFORM := android-9
Edit Android.mk to specify a build path (using cwd otherwise):
LOCAL_PATH = /Users/doug/projects/core/deps/sdl/SDL
Then run ndk-build in android-build. It’ll generate output like:
~projects/core/android-build$ ~/projects/libs/android-ndk/ndk-build
Compile thumb : sdl <= SDL.c
Compile thumb : sdl <= SDL_assert.c
Compile thumb : sdl <= SDL_error.c
Compile thumb : sdl <= SDL_fatal.c
Compile thumb : sdl <= SDL_hints.c
…
Compile thumb : sdl <= SDL_androidvideo.c
Compile thumb : sdl <= SDL_androidwindow.c
SharedLibrary : libsdl.so
Install : libsdl.so => libs/armeabi/libsdl.so
That binary: libs/armeabi/libsdl.so is a binary target you can link
against or dlopen from your app.
(You’ll want to customize Application.mk if you want to build for other
platforms)
(Just my $0.02, but configure is broken and useless for
cross compilation like this; even if you create a custom toolchain and try
to invoke it, it’ll still screw up and try to either 1) link the wrong
files or 2) just fall over for no reason. Stay away if you value your
sanity)
~
Doug.
On Thu, Jan 10, 2013 at 1:57 AM, ?lvaro Castro-Castilla < @Alvaro_Castro-Castil> wrote:
Currently, I’m trying to cross-compile it with configure
–host=arm-linux-androideabi, but it fails when trying to compile
SDL_x11opengl.c