Static Prebuilt libraries and their dependencies

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Static Prebuilt libraries and their dependencies

Kartik Aiyer
  • I have prebuilt binaries of opencv as static libraries built using the android NDK r16 for arm64-v8a & armeabi-v7a.
  • I’m trying to use these binaries as is in an AOSP build for the same above two architectures.
  • The output of the opencv prebuild seems to have separated the opencv specific .a files from the 3rdparty .a files. I gather this means to link successfully I will have to include both the opencv library (eg libopencvcore.a) as well as the third-party dependency (libtbb.a). _I’m not sure how to specify the 3rdparty dependency in the static prebuild module description.

This is folder structure of the opencv output

sdk
  └── native
    ├── 3rdparty
    │   └── libs
    │       ├── arm64-v8a
    │       │   ├── libcpufeatures.a
    │       │   └── libtbb.a
    │       ├── armeabi-v7a
    │       │   ├── libcpufeatures.a
    │       │   └── libtbb.a
    │       ├── x86
    │       │   ├── libcpufeatures.a
    │       │   ├── libittnotify.a
    │       │   └── libtbb.a
    │       └── x86_64
    │           ├── libcpufeatures.a
    │           ├── libittnotify.a
    │           └── libtbb.a
    ├── jni
    │   ├── android.toolchain.cmake
    │   ├── include
    │   │   ├── opencv
    │   │   │   ├── cvaux.h
    |   |   |   ...
    │   │   └── opencv2
    │   │       ├── core
    └── libs
        ├── arm64-v8a
        │   ├── libopencv_core.a
        │   ├── libopencv_features2d.a
        │   ├── libopencv_imgproc.a
        │   └── libopencv_video.a
        ├── armeabi-v7a
        │   ├── libopencv_core.a
        │   ├── libopencv_features2d.a
        │   ├── libopencv_imgproc.a
        │   └── libopencv_video.a
        ├── x86
        │   ├── libopencv_core.a
        │   ├── libopencv_features2d.a
        │   ├── libopencv_imgproc.a
        │   └── libopencv_video.a
        └── x86_64
            ├── libopencv_core.a
            ├── libopencv_features2d.a
            ├── libopencv_imgproc.a
            └── libopencv_video.a

The dependencies are in the 3rdparty folder.
I created an Android.mk file that makes PREBUILDs out of all the opencv libraries, but I’m not sure how to add the dependencies to the prebuilt module.

This is my current Android.mk file

ROOT_DIR := $(call my-dir)

LOCAL_PATH := $(ROOT_DIR)/core-libs/opencv/Android/sdk/native/libs
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_core_prebuilt
LOCAL_MULTILIB := both
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_SUFFIX := .a
LOCAL_SRC_FILES_64 := arm64-v8a/libopencv_core.a
LOCAL_SRC_FILES_32 := armeabi-v7a/libopencv_core.a
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../jni/include
LOCAL_EXPORT_CFLAGS_64 := -L$(LOCAL_PATH)/../3rdparty/libs/arm64-v8a -llibtbb.a -llibcpufeatures.a
LOCAL_EXPORT_CFLAGS_32 := -L$(LOCAL_PATH)/../3rdparty/libs/armeabi-v7a -llibtbb.a -llibcpufeatures.a
include $(BUILD_PREBUILT)

include $(CLEAR_VARS)
LOCAL_MODULE := opencv_features2d_prebuilt
LOCAL_MULTILIB := both
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_SUFFIX := .a
LOCAL_SRC_FILES_64 := arm64-v8a/libopencv_features2d.a
LOCAL_SRC_FILES_32 := armeabi-v7a/libopencv_features2d.a
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../jni/include 
include $(BUILD_PREBUILT)

include $(CLEAR_VARS)
LOCAL_MODULE := opencv_imgproc_prebuilt
LOCAL_MULTILIB := both 
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_SUFFIX := .a
LOCAL_SRC_FILES_64 := arm64-v8a/libopencv_imgproc.a
LOCAL_SRC_FILES_32 := armeabi-v7a/libopencv_imgproc.a
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../jni/include 
include $(BUILD_PREBUILT)

include $(CLEAR_VARS)
LOCAL_MODULE := opencv_video_prebuilt
LOCAL_MULTILIB := both
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_SUFFIX := .a
LOCAL_SRC_FILES_64 := arm64-v8a/libopencv_video.a
LOCAL_SRC_FILES_32 := armeabi-v7a/libopencv_video.a
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../jni/include 
include $(BUILD_PREBUILT)

When I try to link to the opencv prebuilds sure enough I get undefined references for calls into libtbb.

How do I specify the libtbb dependency and how to do I make sure the corresponding 3rdparty .a file is linked together.

Can I add it to the LOCAL_SRC_FILES variable ?

Thanks
Kartik

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Static Prebuilt libraries and their dependencies

Colin Cross
The platform build does not support transitive static dependencies.  You'll need to add another prebuilt module for libbb.a, and then either add it as a dependency everywhere you use the opencv prebuilts, or combine them into a single static library:

include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_core_plus_tbb
LOCAL_WHOLE_STATIC_LIBRARIES := opencv_core_prebuilt libtbb_prebuilt
include $(BUILD_STATIC_LIBRARY)

Also, it would be more accurate to use LOCAL_SRC_FILES_arm64 and LOCAL_SRC_FILES_arm instead of LOCAL_SRC_FILES_64 and LOCAL_SRC_FILES_32.



On Tue, Jun 19, 2018 at 1:03 PM Kartik Aiyer <[hidden email]> wrote:
  • I have prebuilt binaries of opencv as static libraries built using the android NDK r16 for arm64-v8a & armeabi-v7a.
  • I’m trying to use these binaries as is in an AOSP build for the same above two architectures.
  • The output of the opencv prebuild seems to have separated the opencv specific .a files from the 3rdparty .a files. I gather this means to link successfully I will have to include both the opencv library (eg libopencvcore.a) as well as the third-party dependency (libtbb.a). _I’m not sure how to specify the 3rdparty dependency in the static prebuild module description.

This is folder structure of the opencv output

sdk
  └── native
    ├── 3rdparty
    │   └── libs
    │       ├── arm64-v8a
    │       │   ├── libcpufeatures.a
    │       │   └── libtbb.a
    │       ├── armeabi-v7a
    │       │   ├── libcpufeatures.a
    │       │   └── libtbb.a
    │       ├── x86
    │       │   ├── libcpufeatures.a
    │       │   ├── libittnotify.a
    │       │   └── libtbb.a
    │       └── x86_64
    │           ├── libcpufeatures.a
    │           ├── libittnotify.a
    │           └── libtbb.a
    ├── jni
    │   ├── android.toolchain.cmake
    │   ├── include
    │   │   ├── opencv
    │   │   │   ├── cvaux.h
    |   |   |   ...
    │   │   └── opencv2
    │   │       ├── core
    └── libs
        ├── arm64-v8a
        │   ├── libopencv_core.a
        │   ├── libopencv_features2d.a
        │   ├── libopencv_imgproc.a
        │   └── libopencv_video.a
        ├── armeabi-v7a
        │   ├── libopencv_core.a
        │   ├── libopencv_features2d.a
        │   ├── libopencv_imgproc.a
        │   └── libopencv_video.a
        ├── x86
        │   ├── libopencv_core.a
        │   ├── libopencv_features2d.a
        │   ├── libopencv_imgproc.a
        │   └── libopencv_video.a
        └── x86_64
            ├── libopencv_core.a
            ├── libopencv_features2d.a
            ├── libopencv_imgproc.a
            └── libopencv_video.a

The dependencies are in the 3rdparty folder.
I created an Android.mk file that makes PREBUILDs out of all the opencv libraries, but I’m not sure how to add the dependencies to the prebuilt module.

This is my current Android.mk file

ROOT_DIR := $(call my-dir)

LOCAL_PATH := $(ROOT_DIR)/core-libs/opencv/Android/sdk/native/libs
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_core_prebuilt
LOCAL_MULTILIB := both
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_SUFFIX := .a
LOCAL_SRC_FILES_64 := arm64-v8a/libopencv_core.a
LOCAL_SRC_FILES_32 := armeabi-v7a/libopencv_core.a
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../jni/include
LOCAL_EXPORT_CFLAGS_64 := -L$(LOCAL_PATH)/../3rdparty/libs/arm64-v8a -llibtbb.a -llibcpufeatures.a
LOCAL_EXPORT_CFLAGS_32 := -L$(LOCAL_PATH)/../3rdparty/libs/armeabi-v7a -llibtbb.a -llibcpufeatures.a
include $(BUILD_PREBUILT)

include $(CLEAR_VARS)
LOCAL_MODULE := opencv_features2d_prebuilt
LOCAL_MULTILIB := both
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_SUFFIX := .a
LOCAL_SRC_FILES_64 := arm64-v8a/libopencv_features2d.a
LOCAL_SRC_FILES_32 := armeabi-v7a/libopencv_features2d.a
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../jni/include 
include $(BUILD_PREBUILT)

include $(CLEAR_VARS)
LOCAL_MODULE := opencv_imgproc_prebuilt
LOCAL_MULTILIB := both 
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_SUFFIX := .a
LOCAL_SRC_FILES_64 := arm64-v8a/libopencv_imgproc.a
LOCAL_SRC_FILES_32 := armeabi-v7a/libopencv_imgproc.a
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../jni/include 
include $(BUILD_PREBUILT)

include $(CLEAR_VARS)
LOCAL_MODULE := opencv_video_prebuilt
LOCAL_MULTILIB := both
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_SUFFIX := .a
LOCAL_SRC_FILES_64 := arm64-v8a/libopencv_video.a
LOCAL_SRC_FILES_32 := armeabi-v7a/libopencv_video.a
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../jni/include 
include $(BUILD_PREBUILT)

When I try to link to the opencv prebuilds sure enough I get undefined references for calls into libtbb.

How do I specify the libtbb dependency and how to do I make sure the corresponding 3rdparty .a file is linked together.

Can I add it to the LOCAL_SRC_FILES variable ?

Thanks
Kartik

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Static Prebuilt libraries and their dependencies

Tran Hung
In reply to this post by Kartik Aiyer
I guess you're talking about:  Add build dependencies 

Best regards,
Hung Tran


--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/d/optout.