Android.mk包含预建库

时间:2018-02-06 20:54:53

标签: android android-ndk android.mk

我很难在Android上编译模块。它引用了一个已经存在的共享库 - 我只有.so和.h文件。

我目前的Android.mk看起来像这样:

LOCAL_PATH:= $(call my-dir)
EXEC_ARCH := armeabi-v7a    

local_vendorlib_c_includes := $(LOCAL_PATH)/VENDORLIB/include

# VENDORLIBWrapper library
include $(CLEAR_VARS)

LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_SRC_FILES := mylib.cpp
LOCAL_MODULE:= libvendorwrapper
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
LOCAL_LDLIBS := -L$(LOCAL_PATH)/DPS/$(EXEC_ARCH)/
LOCAL_C_INCLUDES := \
    $(call include-path-for, graphics corecg) \
    $(call include-path-for, audio-effects) \
    $(local_dps_c_includes)

LOCAL_CPPFLAGS += -O2 -Wno-unused-parameter
#--verbose

LOCAL_SHARED_LIBRARIES := \
    libcutils \
    libdl \
    libVendorLib
#LOCAL_PREBUILT_LIBS += libVendorLib
LOCAL_REQUIRED_MODULES := libVendorLib

include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE := libVendorLib
LOCAL_SRC_FILES := $(LOCAL_PATH)/VendorLib/$(EXEC_ARCH)/libVendorLib.so
LOCAL_MODULE_TAGS := debug
LOCAL_EXPORT_C_INCLUDES := $(local_vendorlib_c_includes)
include $(PREBUILT_SHARED_LIBRARY)


include $(call all-makefiles-under,$(LOCAL_PATH))

我收到以下错误:

> ninja: error:
> 'out/target/product/generic/obj/lib/libVendorLib.so.toc', needed by
> 'out/target/product/generic/obj/SHARED_LIBRARIES/libvendorwrapper_intermediates/LINKED/libvendorwrapper.so', missing and no known rule to make it make: *** [ninja_wrapper] Error 1
> make: Leaving directory `/home/donatoaz/WORKING_DIRECTORY'
> 
> #### make failed to build some targets (23 seconds) ####

1 个答案:

答案 0 :(得分:3)

我能够通过进行以下更改来最终构建它

我能够构建它进行以下更改:

include $(CLEAR_VARS)
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE := libVendorLib
LOCAL_SRC_FILES := libVendorLib.so # <== Moved the prebuilt lib to root / -- oddly enough, when it was in a subfolder, make would not find it.
LOCAL_MODULE_TAGS := debug
LOCAL_EXPORT_C_INCLUDES := $(local_vendorlib_c_includes)
include $(BUILD_PREBUILT) # <== changed this from PREBUILT_SHARED_LIBRARY

现在我明白了:

  成功完成(21秒)