android-project/jni/src/Android_static.mk
author Sam Lantinga <slouken@libsdl.org>
Thu, 10 Oct 2013 21:51:39 -0700
changeset 7804 1f85fb33694b
permissions -rw-r--r--
Fixed bug 2146 - Enable static linking of libSDL on Android Denis Bernard 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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7804
1f85fb33694b Fixed bug 2146 - Enable static linking of libSDL on Android
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
LOCAL_PATH := $(call my-dir)
1f85fb33694b Fixed bug 2146 - Enable static linking of libSDL on Android
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
1f85fb33694b Fixed bug 2146 - Enable static linking of libSDL on Android
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     3
include $(CLEAR_VARS)
1f85fb33694b Fixed bug 2146 - Enable static linking of libSDL on Android
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
1f85fb33694b Fixed bug 2146 - Enable static linking of libSDL on Android
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
LOCAL_MODULE := main
1f85fb33694b Fixed bug 2146 - Enable static linking of libSDL on Android
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
1f85fb33694b Fixed bug 2146 - Enable static linking of libSDL on Android
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
LOCAL_SRC_FILES := YourSourceHere.c
1f85fb33694b Fixed bug 2146 - Enable static linking of libSDL on Android
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
1f85fb33694b Fixed bug 2146 - Enable static linking of libSDL on Android
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
LOCAL_STATIC_LIBRARIES := SDL2_static
1f85fb33694b Fixed bug 2146 - Enable static linking of libSDL on Android
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
1f85fb33694b Fixed bug 2146 - Enable static linking of libSDL on Android
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
include $(BUILD_SHARED_LIBRARY)
1f85fb33694b Fixed bug 2146 - Enable static linking of libSDL on Android
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
$(call import-module,SDL)LOCAL_PATH := $(call my-dir)