Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV 2.4.1: UnsatisfiedLinkError

I have an android project, that has native code. In this native part I use OpenCV. Everything compiles and works OK when I use OpenCV 2.3.1, but when I tried to switch to version 2.4.1, I faced problem:

It compiles without any errors, but when I start my app, it can't load my library because of UnsatisfiedLinkError.

Cannot load library: link_image[1936]:    37 could not load needed library 'libopencv_java.so' for 'mylibrary.so' (load_library[1091]: Library 'libopencv_java.so' not found)

I see that Open CV tries to load libopencv_java.so, but I do not need it and I don't use OpenCV in java code. This library's size >5M.

How to compile without adding this lib to project?

like image 215
Arseniy Avatar asked Jun 05 '12 08:06

Arseniy


1 Answers

The libopencv_java.so in addition to JNI wrappers to C++ OpenCV interface contains all the OpenCV native code.
When you build your JNI library with OpenCV 2.4 for Android you can either link dynamically with libopencv_java.so (default option) and include it into your APK or link statically by adding this option explicitly:

include $(CLEAR_VARS)
OPENCV_LIB_TYPE:=STATIC
include <your path>/OpenCV.mk
like image 131
OpenCV4Android Avatar answered Sep 28 '22 18:09

OpenCV4Android