链接共享的fmod库

时间:2012-10-15 11:34:33

标签: android android-ndk fmod

  

可能重复:
  Loading FMOD purely from native code

我正在尝试在android ndk项目上链接fmod库,但是我遇到了致命的异常错误。

我的android.mk看起来像这样:

LOCAL_PATH := $(call my-dir)

#FMOD Ex Shared Library#########

include $(CLEAR_VARS)

LOCAL_MODULE            := fmodex
LOCAL_SRC_FILES         := libfmodex.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/fmod

include $(PREBUILT_SHARED_LIBRARY)

#lua############################

include $(CLEAR_VARS)

LOCAL_MODULE    := lua
FILE_LIST := $(wildcard $(LOCAL_PATH)/lua/*.c)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)

include $(BUILD_STATIC_LIBRARY)

#libpng########################

include $(CLEAR_VARS)

LOCAL_CFLAGS := 

LOCAL_MODULE    := libpng
FILE_LIST := $(wildcard $(LOCAL_PATH)/libpng/*.c)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)

include $(BUILD_STATIC_LIBRARY)

#ghost##########################

include $(CLEAR_VARS)

LOCAL_MODULE := ghost
FILE_LIST := $(wildcard $(LOCAL_PATH)/ghost/*.cpp)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv2 -L$(SYSROOT)/usr/lib -ldl -L$(SYSROOT)/usr/lib -lz

# Enable debugging.
APP_OPTIM    := debug

# Support for additional libraries
#LOCAL_CFLAGS := -DANDROID_NDK -Wno-psabi
LOCAL_C_INCLUDES := $(LOCAL_PATH)/libpng/ $(LOCAL_PATH)/lua/
LOCAL_SHARED_LIBRARIES := fmodex
LOCAL_STATIC_LIBRARIES := libpng android_native_app_glue lua

include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/native_app_glue)

ndk-build命令成功没有任何错误,但是当我编译时,我收到以下错误:

10-15 14:25:49.220: E/AndroidRuntime(16255): FATAL EXCEPTION: main
10-15 14:25:49.220: E/AndroidRuntime(16255): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.native_activity/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/data/com.example.native_activity/lib/libghost.so
10-15 14:25:49.220: E/AndroidRuntime(16255):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
10-15 14:25:49.220: E/AndroidRuntime(16255):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
10-15 14:25:49.220: E/AndroidRuntime(16255):    at android.app.ActivityThread.access$1500(ActivityThread.java:121)
10-15 14:25:49.220: E/AndroidRuntime(16255):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
10-15 14:25:49.220: E/AndroidRuntime(16255):    at android.os.Handler.dispatchMessage(Handler.java:99)
10-15 14:25:49.220: E/AndroidRuntime(16255):    at android.os.Looper.loop(Looper.java:130)
10-15 14:25:49.220: E/AndroidRuntime(16255):    at android.app.ActivityThread.main(ActivityThread.java:3701)
10-15 14:25:49.220: E/AndroidRuntime(16255):    at java.lang.reflect.Method.invokeNative(Native Method)
10-15 14:25:49.220: E/AndroidRuntime(16255):    at java.lang.reflect.Method.invoke(Method.java:507)
10-15 14:25:49.220: E/AndroidRuntime(16255):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
10-15 14:25:49.220: E/AndroidRuntime(16255):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
10-15 14:25:49.220: E/AndroidRuntime(16255):    at dalvik.system.NativeStart.main(Native Method)
10-15 14:25:49.220: E/AndroidRuntime(16255): Caused by: java.lang.IllegalArgumentException: Unable to load native library: /data/data/com.example.native_activity/lib/libghost.so
10-15 14:25:49.220: E/AndroidRuntime(16255):    at android.app.NativeActivity.onCreate(NativeActivity.java:199)
10-15 14:25:49.220: E/AndroidRuntime(16255):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-15 14:25:49.220: E/AndroidRuntime(16255):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
10-15 14:25:49.220: E/AndroidRuntime(16255):    ... 11 more

如果我删除以下行,代码将在没有fmod支持的情况下编译并正常运行。

include $(CLEAR_VARS)
LOCAL_MODULE            := fmodex
LOCAL_SRC_FILES         := libfmodex.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/fmod

include $(PREBUILT_SHARED_LIBRARY)

LOCAL_SHARED_LIBRARIES := fmodex

我尝试使用fmod示例编译本机活动,令我惊讶的是它有效。我甚至将我的文件位置调整为示例,但它没有帮助。

任何帮助都将不胜感激。

0 个答案:

没有答案