We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2146 - [patch] Enable static linking of libSDL on Android
Summary: [patch] Enable static linking of libSDL on Android
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: build (show other bugs)
Version: HG 2.0
Hardware: All Android (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-10 14:39 UTC by Denis Bernard
Modified: 2013-10-11 04:52 UTC (History)
1 user (show)

See Also:


Attachments
Static build patch (2.47 KB, patch)
2013-10-10 14:39 UTC, Denis Bernard
Details | Diff
Static build patch (2.41 KB, patch)
2013-10-10 22:19 UTC, Denis Bernard
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Denis Bernard 2013-10-10 14:39:23 UTC
Created attachment 1359 [details]
Static build patch

This patch to Android.mk adds support for static linking of libSDL for Android applications. A patched readme with static build instructions is also provided.

It does not break existing build environments setup according to the README-android.txt since the static library version will not be built in not required.

The static build uses the Android NDK module system (see docs/IMPORT-MODULE.html in the NDK folder and step 5 in the instructions below).

Instructions:
1. Copy the android-project directory wherever you want to keep your projects
   and rename it to the name of your project.
2. Create a symlink to SDL/src/main/android/SDL_android_main.c as 
   <project>/jni/src/SDL_android_main.c
3. Rename <project>/jni/src/Android_static.mk to <project>/jni/src/Android.mk
   (overwrite the existing one)
4. Edit <project>/jni/src/Android.mk to include your source files
5. create and export an environment variable named NDK_MODULE_PATH that points
   to the parent directory of this SDL directory. e.g.:

   export NDK_MODULE_PATH="$PWD"/..

6. Edit <project>/src/org/libsdl/app/SDLActivity.java and remove the call to
   System.loadLibrary("SDL2") line 42.
7. Run 'ndk-build' (a script provided by the NDK). This compiles the C source

Although this requires an environment variable to be setup, it can be added once and for all to the main Android.mk of the project.
Comment 1 Denis Bernard 2013-10-10 22:19:27 UTC
Created attachment 1360 [details]
Static build patch

New patch that removes the need to symlink to SDL_android_main.c
Comment 2 Sam Lantinga 2013-10-11 04:52:11 UTC
Looks good, thanks!
http://hg.libsdl.org/SDL/rev/1f85fb33694b