android 关于mk如何引用其它so库

通常,开发android的软件,常常需要编译so库,然编译的这个so库,需要调用多个其它的so库。这里主要记录一下,编译so库时,调用其它so库的mk,是怎么写的。

这里讲的示例:需要编译出libtest3.so,它需要调用libtest1.so,libtest2.so

1. 在android 源码下编译

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := eng

LOCAL_SRC_FILES := \
	test3.cpp

LOCAL_C_INCLUDES += \
	$(LOCAL_PATH)/include/ \
	external/libpiccreader/
LOCAL_MODULE := libtest3
#LOCAL_LDLIBS += -lpthread -ldl
LOCAL_SHARED_LIBRARIES := liblog \
		libcutils \
		libutils \
		libtest1 \
		libtest2
include $(BUILD_SHARED_LIBRARY)
2. 在NDK的环境下编译

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE    := libtest1
LOCAL_SRC_FILES := libtest1.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := libtest2
LOCAL_SRC_FILES := libtest2.so
include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := eng

LOCAL_SRC_FILES := \
	test3.cpp

LOCAL_MODULE := libtest3
LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog 
LOCAL_SHARED_LIBRARIES := liblog \
		libcutils \
		libutils \
		libtest1 \
		libtest2
include $(BUILD_SHARED_LIBRARY)

你可能感兴趣的:(android开发)