Search code examples
androidandroid-ndkandroid-build

How to restrict Android.mk to compile a module to generate only 64bit library


I am able to integarte a 64 bit prebuilt library "x" in android for arm platform and when i try calling that libary in required module which will compile for both 32bit and 64bit library failed mentioning 32 bit library of "x" is not found. /out/target/product/xxxx/system/lib64/libxxxx.so

  1. prebuilt library makefile
    LOCAL_PATH := $(call my-dir)
    include $(CLEAR_VARS)
    LOCAL_SRC_FILES := libfoo.so
    LOCAL_MODULE := libfoo
    LOCAL_MODULE_SUFFIX := .so
    LOCAL_MODULE_CLASS := SHARED_LIBRARIES
    LOCAL_MODULE_PATH := $(TARGET_OUT)/lib64
    LOCAL_MODULE_TAGS := debug
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
    include $(BUILD_PREBUILT
  1. Linking module Makefile
    include $(CLEAR_VARS)
    LOCAL_SRC_FILES := \
        test.c 
        
    LOCAL_SHARED_LIBRARIES := \
        liblog \
        libcutils 

    LOCAL_C_INCLUDES += $(LOCAL_PATH)/include

    ifeq ($(TARGET_ARCH),arm64)
       LOCAL_SHARED_LIBRARIES   += libfoo.so
    endif

    LOCAL_CFLAGS += -Wall -Werror 
    LOCAL_MODULE := vtest
    LOCAL_MODULE_RELATIVE_PATH := test
    LOCAL_MODULE_TAGS := optional
    include $(BUILD_SHARED_LIBRARY)
ninja: error: 'out/target/product/xxxx/obj_arm/SHARED_LIBRARIES/libxxxx_intermediates/export_includes', needed by 'out/target/product/xxxx/obj_arm/SHARED_LIBRARIES/yyyyy/import_includes', missing and no known rule to make it

i want to restrict the linking module to build only for 64 bit not for 32 bit, i tried following but not working ifeq ($(TARGET_ARCH),arm64) LOCAL_SHARED_LIBRARIES += libxxx endif

Please provide suggestions to resolve this issue


Solution

  • At last fixed by following changes and it worked

    LOCAL_MODULE_TARGET_ARCH := arm64
    LOCAL_LDLIBS += $(LOCAL_PATH)/libfoo.so
                                                            
    

    instead of

     ifeq ($(TARGET_ARCH),arm64)
       LOCAL_SHARED_LIBRARIES   += libfoo.so
    endif
    

    @maurice you are partially correct thanks for your input its LOCAL_LDLIBS helped along with Target Arch