Ask Your Question

Revision history [back]

Build modules individually for android

Hello,

OpenCV's Android SDK comes with the built library libopencv_java.so, however, I would like to have one .so file per module, just like it is for windows :

opencv_core248.dll => opencv_core248.so

opencv_imgproc248.dll => opencv_imgproc248.so

opencv_highgui248.dll => opencv_highgui248.so

...etc

I still have not found a proper solution to do this, even if I managed to build opencv_core248.so, I struggle with highgui because of the big number of dependencies... Anyway, here is the Android.mk file I did to build opencv_core248.so :

LOCAL_PATH := $(call my-dir)
MY_OPENCV_INCLUDE_PATH := $(LOCAL_PATH)/sources/include
MY_OPENCV_CORE_PATH := $(LOCAL_PATH)/sources/modules/core/src
MY_OPENCV_CORE_INCLUDE_PATH := $(LOCAL_PATH)/sources/modules/core/include
MY_DYNAMICUDA_INDLUDE_PATH := $(LOCAL_PATH)/sources/modules/dynamicuda/include

#Build OpenCV_core
include $(CLEAR_VARS)
LOCAL_LDLIBS    += -lz -llog
LOCAL_C_INCLUDES += $(MY_OPENCV_INCLUDE_PATH)
LOCAL_C_INCLUDES += $(MY_OPENCV_CORE_INCLUDE_PATH)
LOCAL_C_INCLUDES += $(MY_DYNAMICUDA_INDLUDE_PATH)
LOCAL_MODULE    := opencv_core248
LOCAL_SRC_FILES :=  $(MY_OPENCV_CORE_PATH)/algorithm.cpp $(MY_OPENCV_CORE_PATH)/alloc.cpp $(MY_OPENCV_CORE_PATH)/arithm.cpp $(MY_OPENCV_CORE_PATH)/array.cpp $(MY_OPENCV_CORE_PATH)/cmdparser.cpp $(MY_OPENCV_CORE_PATH)/convert.cpp $(MY_OPENCV_CORE_PATH)/copy.cpp $(MY_OPENCV_CORE_PATH)/datastructs.cpp $(MY_OPENCV_CORE_PATH)/drawing.cpp $(MY_OPENCV_CORE_PATH)/dxt.cpp $(MY_OPENCV_CORE_PATH)/gl_core_3_1.cpp $(MY_OPENCV_CORE_PATH)/glob.cpp $(MY_OPENCV_CORE_PATH)/gpumat.cpp $(MY_OPENCV_CORE_PATH)/lapack.cpp $(MY_OPENCV_CORE_PATH)/mathfuncs.cpp $(MY_OPENCV_CORE_PATH)/matmul.cpp $(MY_OPENCV_CORE_PATH)/matop.cpp $(MY_OPENCV_CORE_PATH)/matrix.cpp $(MY_OPENCV_CORE_PATH)/opengl_interop.cpp $(MY_OPENCV_CORE_PATH)/opengl_interop_deprecated.cpp $(MY_OPENCV_CORE_PATH)/out.cpp $(MY_OPENCV_CORE_PATH)/parallel.cpp $(MY_OPENCV_CORE_PATH)/persistence.cpp $(MY_OPENCV_CORE_PATH)/rand.cpp $(MY_OPENCV_CORE_PATH)/stat.cpp $(MY_OPENCV_CORE_PATH)/system.cpp $(MY_OPENCV_CORE_PATH)/tables.cpp
include $(BUILD_SHARED_LIBRARY)

So, I hope I was clear enough, how to properly generate one .so file per module ?