Android NDK:使用 OpenAL 共享库时出现 UnsatisfiedLinkError

问题描述 投票:0回答:1

我正在尝试在 Android 中使用手动编译的 OpenAL 共享库。

include $(CLEAR_VARS)
LOCAL_MODULE:=openal
LOCAL_SRC_FILES:=../mylibs/libopenal.so
LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)/include/AL
include $(PREBUILT_SHARED_LIBRARY)

在 mylibs 文件夹中我有 3 个文件:

lrwxr-xr-x  21:12 libopenal.so -> libopenal.so.1
lrwxr-xr-x  21:12 libopenal.so.1 -> libopenal.so.1.13.0
-rwxr-xr-x  22:33 libopenal.so.1.13.0

一切都很好,但在运行时我收到此错误:

E/AndroidRuntime(13604): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library:         link_image[1848]:  1296 could not load needed library 'libopenal.so.1' for 'libopenaltest.so'     (load_library[1120]: Library 'libopenal.so.1' not found)
E/AndroidRuntime(13604):    at java.lang.Runtime.loadLibrary(Runtime.java:370)
E/AndroidRuntime(13604):    at java.lang.System.loadLibrary(System.java:535)
E/AndroidRuntime(13604):    at com.hz.openal.OpenActivity.<clinit>(OpenActivity.java:10)
E/AndroidRuntime(13604):    ... 15 more

谁能帮我解决这个问题吗?

android android-ndk openal
1个回答
1
投票

尝试这样:

LOCAL_MODULE := lib3rdparty-prebuilt
LOCAL_SRC_FILES := lib3rdparty.so
include $(PREBUILT_SHARED_LIBRARY)

LOCAL_SHARED_LIBRARIES += lib3rdparty-prebuilt

我认为你错过了最后一行

LOCAL_SHARED_LIBRARIES
.....

而且在加载“libopenaltest.so”库之前您也没有加载“libopenal.so”库。在加载依赖库之前,需要使用

System.loadLibrary()
加载所有库。

© www.soinside.com 2019 - 2024. All rights reserved.