hyamanyar
hyamanyar

Reputation: 41

How can I create *.so files to Dynamically Link OpenCV for Android?

I'd like to generate libopencv_java.so file from OpenCV 2.4.x source files and libopencv3_java.so from OpenCV 3.x.x source files in order to be able to link OpenCV library dynamically to my Android Application.

Although I can rebuild statically linked *.a library files (e.g. libopencv_core.a & libopencv_imgproc.a) from trunk by means of CMake & MinGW using "Unix makefiles" on a Win64-based development machine for "armeabi-v7a, arm64-v8a, x86 & x86_64" targets; I cannot reproduce the dynamically linked libopencv_java & libopencv3_java.so files and I cannot find any relevant information regarding this issue on OpenCV website or any other knowledge base.

Could anybody please explain to me how to generate these *.so files on a Win64-based development machine by means of CMake & MinGW? I want to make small changes in some of the OpenCV source files and then reproduce everything from scratch.

Using "Unix makefiles" or "MinGW makefiles" or any other configuration doesn't really matter as long as it works properly.

Thanks in Advance

Upvotes: 3

Views: 1834

Answers (2)

Ayush Goel
Ayush Goel

Reputation: 21

What needs to be done in order to generate the opencv_java is that you need to have python2, java, ant-executable installed in your system. And if i am guessing correct you must be using cmake for generating the .a files. In case your are using some different methods follow the step in the following link: http://amin-ahmadi.com/2017/08/13/how-to-build-opencv-3-3-x-for-android/ Following the steps mentioned in above liink you should be able to generate the opencv_java file.

Upvotes: 0

hyamanyar
hyamanyar

Reputation: 41

For those who may encounter with a similar problem in the future, I solved this problem by placing newly created *.a files for a specific architecture (armeabi-v7a, arm64-v8a, x86, x86_64 and so on) into their proper place under OpenCV Android prebuilt libraries folder and rebuilding "libopencv_java3.so" under that folder by means of my own Android.mk and Application.mk files. I also used only Python 3 for the code generation phase of "BUILD_opencv_java" and "BUILD_FAT_JAVA_LIB" components, instead of using Python 2 and Python 3 together.

Upvotes: 1

Related Questions