2

我有 4 个静态库libavcodec.a libavutil.a libswscale.a libx264.a

我想把它与libmytest.so

我在 Android.mk 脚本下面试过

LOCAL_PATH := $(call my-dir)
INITIAL_PATH := $(LOCAL_PATH)

include $(CLEAR_VARS)
LOCAL_MODULE := mytest

LOCAL_SRC_FILES := mytest.c

LOCAL_LDLIBS += -llog
LOCAL_WHOLE_STATIC_LIBRARIES := libavutil libavcodec libswscale libx264

include $(BUILD_SHARED_LIBRARY)

mytest.c从这些库中调用许多函数。4 个库被放置在PROJECTPATH\jni\.

但是我undefined reference从这些库中获得了所有功能。

我尝试给予LOCAL_ALLOW_UNDEFINED_SYMBOLS := true允许我创建共享库,但是当我启动应用程序时,我得到

01-22 07:15:15.650: E/AndroidRuntime(9655): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1285]:  1868 cannot locate 'avcodec_register_all'...
01-22 07:15:15.650: E/AndroidRuntime(9655):     at java.lang.Runtime.loadLibrary(Runtime.java:370)
01-22 07:15:15.650: E/AndroidRuntime(9655):     at java.lang.System.loadLibrary(System.java:535)
4

1 回答 1

3

PREBUILT_STATIC_LIBRARY如果您不从源代码构建它们,则需要为每个库定义一个,例如

include $(CLEAR_VARS)
LOCAL_MODULE := avutil
LOCAL_SRC_FILES := $(LOCAL_PATH)/jni/libavutil.a
include $(PREBUILT_STATIC_LIBRARY)

... [重复其他预建库]。

LOCAL_STATIC_LIBRARIES只理解模块名称,即stuff that have been declared through their own ndk-build module definition. 我很惊讶它没有提供有关缺少模块的警告,但它是与您的问题相对应的最有可能的解释。

于 2014-02-03T03:20:44.063 回答