在Android中将预构建的静态库包含到共享库中

时间:2011-12-03 11:28:04

标签: makefile android-ndk shared-libraries static-libraries

我有预构建的静态c ++库(顺便说一下,它的大小约为12.8 MB),我希望将它包含在共享库中。

Android.mk:

LOCAL_PATH := $(call my-dir)

LOCAL_ARM_MODE := arm
LOCAL_MODULE := MyLib
LOCAL_SRC_FILES := libMyLib.a

include $(PREBUILT-STATIC-LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE    := test
LOCAL_SRC_FILES := test.cpp
LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
LOCAL_STATIC_LIBRARIES := MyLib
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)

它构建没有错误,但libtest.so大约34 kb。我以为它会消耗MyLib.a

这个Android上的应用大约需要76kb。

无论如何,当我尝试在android上执行它时,我会在日志中看到:

12-03 12:21:26.806: I/dalvikvm(8976): Unable to dlopen(/data/data/com.test/lib/libtest.so): Cannot load library: reloc_library[1245]:  1099 cannot locate '<some long-long string>'...

1 个答案:

答案 0 :(得分:0)

(在评论中回答:Question with no answers, but issue solved in the comments (or extended in chat)

OP写道:

  

必须是:LOCAL_LDLIBS := -llog -ldl -L.点很重要