Java - Can't find dependent libraries

asked 2018-04-22 11:41:13 -0500

Chrono7 gravatar image

So I built OpenCV with CMake using Visual Studio 2017 and I'm trying to use the Java bindings.

I built it with "cmake.exe --build . --config Release --target INSTALL".

In IntelliJ, I add the JAR as a library and add the native library location D:\Documents\opencv\opencv2\opencv-3.4.1\build\install\java, which contains opencv_java341.dll.

When I try to run my java code, I get the error Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\Documents\opencv\opencv2\opencv-3.4.1\build\install\java\opencv_java341.dll: Can't find dependent libraries.

One thing I noticed is that when I tried with the prebuilt version (which seems to work but doesn't have the contrib modules), opencv_java341.dll is 45,140 KB while the one I built is only 2,063 KB.

What should I do?

edit retag flag offensive close merge delete


you probably did NOT build with BUILD_SHARED_LIBS=OFF , so your opencv_java.dll depends on the other opencv libs, like opencv_core.dll opencv_imgproc.dll, etc.

those must be found at runtime, so put your opencv/build/install/bin folder on the system's PATH variable.

berak gravatar imageberak ( 2018-04-23 02:17:57 -0500 )edit