在Android上使用第三方共享库,在Unity3D上使用NDK

时间:2013-09-14 16:02:37

标签: android plugins android-ndk

我正在尝试使用NDK制作一个使用FMOD for Android的Android插件(我需要这是原生的,因为我也使用需要与FMOD交互的第三方开源C ++库,工作正常)。 我可以使用NDK编译所有内容,但是当我创建Unity项目时,如果我使用FMOD共享库,我总是会得到DLLNotFoundException。 请注意,如果我不包含任何FMOD调用,我创建的共享库工作正常,所以我很确定Unity播放器无法找到FMOD共享库。

这是我的插件代码:

extern "C" {
#endif

    static int mycount = 0;
    int FooTest(){

        unsigned int version;
        FMOD::System* system_;

        //Init
        FMOD_RESULT result = FMOD::System_Create(&system_);
        if (result != FMOD_OK) return -1;

        result = system_->getVersion(&version);
        if (result != FMOD_OK) return -1;

        if (version < FMOD_VERSION)
        {
            //printf("Error!  You are using an old version of FMOD %08x.  This program requires %08x\n", version, FMOD_VERSION);
            return -1;
        }
        result = system_->init(32, FMOD_INIT_NORMAL, 0);
        if (result != FMOD_OK) return -1;

        return mycount++;
    }


#ifdef __cplusplus
}
#endif

如果我注释掉所有FMOD内容,则返回的计数会递增并显示在屏幕上。每当我使用FMOD调用构建时,我都会收到“DLLNotFoundException:FooTest”

我在我的插件/ android目录和项目的根目录中都包含了fmodex.so和fmodexL.so库,并且我已经检查它们是否存在于生成的APK的lib / armeabi文件夹中。

如果有人有兴趣,我也可以发布我用来生成共享库的Android makefile。

1 个答案:

答案 0 :(得分:0)

.so libs必须包含在项目的根目录中才能找到它们。