Loading FMOD purely from native code

孤街浪徒 提交于 2019-11-30 05:21:55

问题


I found an example called nativeactivity in FMOD example folder, but unfortunately it use some java code:

package org.fmod.nativeactivity;

public class Example extends android.app.NativeActivity 
{
    static 
    {
        System.loadLibrary("fmodex");
        System.loadLibrary("main");
    }    
}

Android.mk looks like this:

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)/inc

include $(PREBUILT_SHARED_LIBRARY)

#
# Example Library
#
include $(CLEAR_VARS)

LOCAL_MODULE           := main
LOCAL_SRC_FILES        := main.c
LOCAL_LDLIBS           := -llog -landroid
LOCAL_SHARED_LIBRARIES := fmodex
LOCAL_STATIC_LIBRARIES := android_native_app_glue

include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/native_app_glue)

Is it possible to do without the java part? If so what would I need to change?


回答1:


I don't know why you want to get rid of these few lines of Java. To the best of my knowledge, this has no effect on the rest of your application.

The reason you need Java is that Android system loader cannot find libfmodex.so which is essential to resolve the references in your libghost.so. Therefore, load of libghost.so fails. Java lets you preload the dependency before your library is loaded.

Unfortunately, NativeActivity itself can only load one library. A request has been posted in April 2012 to improve the situation some time in the future.

Currently, you can switch all your code that works with fmod to dynamic linking, or build a third shared library which will load fmod and then load the ghost library. In this situation, the loader will be able to resolve the references in ghost because fmod will already be loaded.



来源:https://stackoverflow.com/questions/11427067/loading-fmod-purely-from-native-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!