From 00568c229a8293d37cbc4ae6e0d1a426af687364 Mon Sep 17 00:00:00 2001 From: Walzer Date: Sat, 25 Jun 2011 11:21:16 +0800 Subject: [PATCH] [android] back to shared library link --- Box2D/Android.mk | 2 +- CocosDenshion/android/Android.mk | 8 +++--- .../android/jni/SimpleAudioEngineJni.cpp | 9 ++++++- HelloWorld/android/jni/Application.mk | 2 +- HelloWorld/android/jni/helloworld/Android.mk | 17 ++++-------- .../cocos2dx/application/ApplicationDemo.java | 2 ++ chipmunk/Android.mk | 2 +- cocos2dx/Android.mk | 23 +++++++++++++--- tests/test.android/jni/Application.mk | 2 +- tests/test.android/jni/tests/Android.mk | 26 +++++++------------ .../src/org/cocos2dx/tests/TestsDemo.java | 4 +++ 11 files changed, 58 insertions(+), 39 deletions(-) diff --git a/Box2D/Android.mk b/Box2D/Android.mk index 31d1a52a15..2c0fcfd3b9 100644 --- a/Box2D/Android.mk +++ b/Box2D/Android.mk @@ -43,4 +43,4 @@ Dynamics/b2WorldCallbacks.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. -include $(BUILD_STATIC_LIBRARY) +include $(BUILD_SHARED_LIBRARY) diff --git a/CocosDenshion/android/Android.mk b/CocosDenshion/android/Android.mk index 5e0348e7d5..93ef096973 100644 --- a/CocosDenshion/android/Android.mk +++ b/CocosDenshion/android/Android.mk @@ -5,7 +5,9 @@ LOCAL_MODULE := cocosdenshion LOCAL_SRC_FILES := SimpleAudioEngine.cpp \ jni/SimpleAudioEngineJni.cpp -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \ - $(LOCAL_PATH)/../../cocos2dx +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include + +LOCAL_LDLIBS := -llog + -include $(BUILD_STATIC_LIBRARY) \ No newline at end of file +include $(BUILD_SHARED_LIBRARY) \ No newline at end of file diff --git a/CocosDenshion/android/jni/SimpleAudioEngineJni.cpp b/CocosDenshion/android/jni/SimpleAudioEngineJni.cpp index 3bed9b355a..2bb2f8d4a7 100644 --- a/CocosDenshion/android/jni/SimpleAudioEngineJni.cpp +++ b/CocosDenshion/android/jni/SimpleAudioEngineJni.cpp @@ -1,5 +1,4 @@ #include "SimpleAudioEngineJni.h" -#include "platform/android/Cocos2dJni.h" #include #define LOG_TAG "libSimpleAudioEngine" @@ -8,9 +7,17 @@ extern "C" { + static JavaVM *gJavaVM = 0; static jclass classOfCocos2dxActivity = 0; JNIEnv *env = 0; + jint JNI_OnLoad(JavaVM *vm, void *reserved) + { + gJavaVM = vm; + + return JNI_VERSION_1_4; + } + static jmethodID getMethodID(const char *methodName, const char *paramCode) { jmethodID ret = 0; diff --git a/HelloWorld/android/jni/Application.mk b/HelloWorld/android/jni/Application.mk index 62edb0eee1..40ab23a70f 100644 --- a/HelloWorld/android/jni/Application.mk +++ b/HelloWorld/android/jni/Application.mk @@ -1,4 +1,4 @@ # it is needed for ndk-r5 APP_STL := stlport_static -APP_MODULES := helloworld \ No newline at end of file +APP_MODULES := cocos2d cocosdenshion helloworld \ No newline at end of file diff --git a/HelloWorld/android/jni/helloworld/Android.mk b/HelloWorld/android/jni/helloworld/Android.mk index d5776ed114..ca8c1504b7 100644 --- a/HelloWorld/android/jni/helloworld/Android.mk +++ b/HelloWorld/android/jni/helloworld/Android.mk @@ -15,22 +15,15 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../cocos2dx \ # it is used for ndk-r4 # if you build with nkd-r4, uncomment it -# LOCAL_LDLIBS := -llog -lGLESv1_CM -lz \ -# -L$(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries -lcurl \ -# -lpng \ -# -lxml2 \ -# -ljpeg +# LOCAL_LDLIBS := -L$(LOCAL_PATH)/../../libs/armeabi -lcocos2d -llog -lcocosdenshion \ +# -L$(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries -lcurl # it is used for ndk-r5 # if you build with ndk-r4, comment it # because the new Windows toolchain doesn't support Cygwin's drive # mapping (i.e /cygdrive/c/ instead of C:/) -LOCAL_LDLIBS := -llog -lGLESv1_CM -lz \ - -L$(call host-path, $(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries) -lcurl \ - -lpng \ - -lxml2 \ - -ljpeg - -LOCAL_STATIC_LIBRARIES := libcocos2d libcocosdenshion +LOCAL_LDLIBS := -L$(call host-path, $(LOCAL_PATH)/../../libs/armeabi) \ + -lcocos2d -llog -lcocosdenshion \ + -L$(call host-path, $(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries) -lcurl include $(BUILD_SHARED_LIBRARY) \ No newline at end of file diff --git a/HelloWorld/android/src/org/cocos2dx/application/ApplicationDemo.java b/HelloWorld/android/src/org/cocos2dx/application/ApplicationDemo.java index 4ffdfa4a58..45e812f09c 100644 --- a/HelloWorld/android/src/org/cocos2dx/application/ApplicationDemo.java +++ b/HelloWorld/android/src/org/cocos2dx/application/ApplicationDemo.java @@ -43,6 +43,8 @@ public class ApplicationDemo extends Cocos2dxActivity{ } static { + System.loadLibrary("cocos2d"); + System.loadLibrary("cocosdenshion"); System.loadLibrary("helloworld"); } } diff --git a/chipmunk/Android.mk b/chipmunk/Android.mk index 92d290c8d3..e84dee18ee 100644 --- a/chipmunk/Android.mk +++ b/chipmunk/Android.mk @@ -35,4 +35,4 @@ src/cpVect.c LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/chipmunk LOCAL_CFLAGS := -std=c99 -include $(BUILD_STATIC_LIBRARY) +include $(BUILD_SHARED_LIBRARY) diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index 473ca9fe4f..60150e47df 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -108,8 +108,25 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \ $(LOCAL_PATH)/platform/third_party/android/libpng \ $(LOCAL_PATH)/platform/third_party/android/libxml2 \ $(LOCAL_PATH)/platform/third_party/android/libjpeg +# it is used for ndk-r4 +# if you build with nkd-r4, uncomment it +# LOCAL_LDLIBS := -L$(LOCAL_PATH)/platform/third_party/android/libraries \ +# -lGLESv1_CM -llog -lz \ +# -lpng \ +# -lxml2 \ +# -ljpeg +# it is used for ndk-r5 +# if you build with ndk-r4, comment it +# because the new Windows toolchain doesn't support Cygwin's drive +# mapping (i.e /cygdrive/c/ instead of C:/) +LOCAL_LDLIBS := -L$(call host-path, $(LOCAL_PATH)/platform/third_party/android/libraries) \ + -lGLESv1_CM -llog -lz \ + -lpng \ + -lxml2 \ + -ljpeg + +# define the macro to compile through support/zip_support/ioapi.c +LOCAL_CFLAGS := -DUSE_FILE32API -LOCAL_CFLAGS := -DUSE_FILE32API - -include $(BUILD_STATIC_LIBRARY) +include $(BUILD_SHARED_LIBRARY) diff --git a/tests/test.android/jni/Application.mk b/tests/test.android/jni/Application.mk index 2d9fb78a72..3fa7ae5711 100644 --- a/tests/test.android/jni/Application.mk +++ b/tests/test.android/jni/Application.mk @@ -2,4 +2,4 @@ APP_STL := stlport_static APP_ABI := armeabi armeabi-v7a -APP_MODULES := tests +APP_MODULES := cocos2d cocosdenshion chipmunk box2d tests diff --git a/tests/test.android/jni/tests/Android.mk b/tests/test.android/jni/tests/Android.mk index 9b5a918e28..c9731e5ff6 100644 --- a/tests/test.android/jni/tests/Android.mk +++ b/tests/test.android/jni/tests/Android.mk @@ -85,28 +85,22 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../cocos2dx \ # it is used for ndk-r4 # if you build with nkd-r4, uncomment it -# LOCAL_LDLIBS := -lGLESv1_CM \ -# -llog \ -# -lz -# -L$(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries -lcurl \ -# -lpng \ -# -lxml2 \ -# -ljpeg +# LOCAL_LDLIBS := -L$(LOCAL_PATH)/../../libs/armeabi \ +# -lGLESv1_CM \ +# -lcocos2d -lcocosdenshion -llog \ +# -lbox2d -lchipmunk \ +# -L$(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries -lcurl # it is used for ndk-r5 # if you build with ndk-r4, comment it # because the new Windows toolchain doesn't support Cygwin's drive # mapping (i.e /cygdrive/c/ instead of C:/) -LOCAL_LDLIBS := -lGLESv1_CM \ - -llog \ - -lz \ - -L$(call host-path, $(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries) -lcurl \ - -lpng \ - -lxml2 \ - -ljpeg - -LOCAL_STATIC_LIBRARIES := libcocos2d libcocosdenshion libbox2d libchipmunk +LOCAL_LDLIBS := -L$(call host-path, $(LOCAL_PATH)/../../libs/armeabi) \ + -lGLESv1_CM \ + -lcocos2d -llog -lcocosdenshion \ + -lbox2d -lchipmunk \ + -L$(call host-path, $(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries) -lcurl include $(BUILD_SHARED_LIBRARY) diff --git a/tests/test.android/src/org/cocos2dx/tests/TestsDemo.java b/tests/test.android/src/org/cocos2dx/tests/TestsDemo.java index ada674d6b6..9adf8f5485 100644 --- a/tests/test.android/src/org/cocos2dx/tests/TestsDemo.java +++ b/tests/test.android/src/org/cocos2dx/tests/TestsDemo.java @@ -46,6 +46,10 @@ public class TestsDemo extends Cocos2dxActivity{ } static { + System.loadLibrary("cocosdenshion"); + System.loadLibrary("chipmunk"); + System.loadLibrary("box2d"); + System.loadLibrary("cocos2d"); System.loadLibrary("tests"); } }