OpenCV 2.4.13.4 dll link error for Java on windows10 OS

asked 2017-11-11 00:03:06 -0600

kmn gravatar image

I am running the following Java code snippet running JVM 1.8 for OpenCV 2.4.13 version:

Java Code Start

public static void main(String[] args){

System.out.println("Welcome to OpenCV " + Core.VERSION); System.loadLibrary(Core.NATIVE_LIBRARY_NAME); Mat m = Mat.eye(3, 3, CvType.CV_8UC1); System.out.println("m = " + m.dump()); }

Java Code End

I get this error:

Welcome to OpenCV 2.4.13.4 Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J at org.opencv.core.Mat.n_eye(Native Method) at org.opencv.core.Mat.eye(Mat.java:1468) at HelloCV.main(HelloCV.java:29)


I have tried the following:

  1. Putting the dll full path name on System.loadLibrary
  2. Passing the dll path to JVM version 1.8
  3. Putting the dll file into the windows system32 folder
  4. Putting the dll path name into eclipse opencv.jar config

Any ideas how this can be resolved

edit retag flag offensive close merge delete

Comments

justsome remarks:

  • the System.loadLibrary() call should go into a static {} block, not into main(), so you're sure it'S loaded before main() gets called.
  • if you want to use the full path, you have to use System.load(), not System.loadLibrary() (and you also have to specify the .dll extension)
  • dlls have to go on the java.library.path, not on the classpath (that's for jars and class files only)
  • maybe you should ditch your complicated ide for a moment, in favour of just using ant
berak gravatar imageberak ( 2017-11-12 10:59:11 -0600 )edit