Linking prebuilt opencv static library in Android.mk
Hi I am trying to link prebuilt external/opencv3 libopencv_core.a in the Android tree to my project that's also in the tree. I get the following error
ninja: error: 'out/target/product/neo/obj/STATIC_LIBRARIES/libopencv_core_prebuilt_intermediates/export_includes', needed by 'out/target/product/neo/obj/STATIC_LIBRARIES/libNV_intermediates/import_includes', missing and no known rule to make it
I am able to link to libopencv_core when Android builds it, but I need to link to opencv3 built with opencl created using the following make.
cd /hdd/NEO8/external/opencv3/platforms
./scripts/cmake_android_arm.sh -DANDROID_ABI=arm64-v8a -DANDROID_NATIVE_API_LEVEL=android-23 -DWITH_OPENCL=yes -DWITH_CUDA=no
cd build_android_arm
make -j8
OpenCV static libraries are created in the lib/arm64-v8a directory.
My project is all native code (c++) with no jni or Java.
The tree structure is:
my_android_tree_root/
external/opencv3 (this is where I build the libopencv_core.a)
device/my_app (this is where my Android.mk is)
The external/opencv3 code is v3.0 downloaded from Google.
I'd attach the Android.mk but this forum only allows image attachments. Below is how I'm adding the prebuilt to the Android.mk
include $(CLEAR_VARS)
PREBUILT_PATH := /hdd/NEO8/external/opencv3/platforms/build_android_arm/lib/arm64-v8a
PREBUILT_INCLUDE_PATH := /hdd/NEO8/external/opencv3
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(PREBUILT_INCLUDE_PATH) \
$(PREBUILT_INCLUDE_PATH)/modules/core/include \
$(PREBUILT_INCLUDE_PATH)/opencv2 \
$(PREBUILT_INCLUDE_PATH)/modules/hal/include
LOCAL_MODULE := libopencv_core_prebuilt
LOCAL_SRC_FILES := $(PREBUILT_PATH)/libopencv_core.a
include $(PREBUILT_STATIC_LIBRARY)
The LOCAL_EXPORT_C_INCLUDE_DIRS is the same as what I use when I link to the Android built opencv3.
I can tell that the Android build process is finding the libopencv_core.a file because when I change the static library name to something bogus, i.e.
LOCAL_SRC_FILES := $(PREBUILT_PATH)/libopencv_core_bogusName.a
the linker says it can't find libopencv_core_bogusName.a.
Is there a way to get more information out of the Android build info like a verbose=true setting? Any ideas on what I can try would be greatly appreciated.
This is the entire Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
PREBUILT_PATH := /hdd/NEO8/external/opencv3/platforms/build_android_arm/lib/arm64-v8a
PREBUILT_INCLUDE_PATH := /hdd/NEO8/external/opencv3
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(PREBUILT_INCLUDE_PATH) \
$(PREBUILT_INCLUDE_PATH)/modules/core/include \
$(PREBUILT_INCLUDE_PATH)/opencv2 \
$(PREBUILT_INCLUDE_PATH)/modules/hal/include
LOCAL_MODULE := libopencv_core_prebuilt
LOCAL_SRC_FILES := $(PREBUILT_PATH)/libopencv_core.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libNV
LOCAL_MODULE_TAGS := optional
LOCAL_VENDOR_MODULE := true
LOCAL_C_INCLUDES := \
external/opencv3/include/opencv \
external/opencv3/include \
external/opencv3/modules/core/include \
external/opencv3/modules/hal/include \
external/opencv3/modules/imgproc/include \
external/opencv3/modules/photo/include \
external/opencv3/modules/video/include \
external/opencv3/modules/objdetect/include \
external/opencv3/modules/features2d/include \
external/opencv3/modules/flann/include \
external/opencv3/modules/calib3d/include \
external/opencv3/modules/imgcodecs/include \
external/opencv3/modules/videoio/include \
external/opencv3/modules/highgui/include \
external/opencv3/modules/ml/include \
external/opencv3/modules/shape/include \
external/opencv3/modules/stitching/include \
external/opencv3/modules/superres/include \
external/opencv3/modules/videostab/include \
external/jsoncpp/include \
device/my_app/apps/external/OpenCL \
$(LOCAL_PATH)/include \
system/core/include
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH)/include
LOCAL_SRC_FILES := \
src/NVOpencv.cpp \
src/NVProcAngles.cpp \
src/NVUtils.cpp \
src/ILogger.cpp
LOCAL_CPPFLAGS := \
-std=c++14 \
-fPIC \
-fsigned-char \
-frtti \
-fexceptions \
-Wno-non-virtual-dtor \
-Wno-unused-parameter \
-Wno-write-strings
LOCAL_STATIC_LIBRARIES := \
libopencv_hal \
libopencv_core_prebuilt
LOCAL_SHARED_LIBRARIES := \
libc++ \
libopencv_imgproc ...
This isn't a solution, but an interesting discovery. There is an example in the Android tree at
development/ndk/tests/prebuilt-library/jni
that follows the instructions at
https://developer.android.com/ndk/gui...
that also gives the same error as I get when built
ninja: error: 'out/target/product/neo/obj/SHARED_LIBRARIES/foo-prebuilt_intermediates/export_includes', needed by 'out/target/product/neo/obj/SHARED_LIBRARIES/foo-user_intermediates/import_includes', missing and no known rule to make it 08:50:08 ninja failed with: exit status 1 make: * [run_soong_ui] Error 1