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

时间:2012-12-01 18:50:13

标签: android android-ndk openal

我正在尝试在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

任何人都可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分: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()加载所有库。