Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Installation Problem: "can't find dependent libraries"

I was recently trying to install OpenCV (the java distribution) on a 64 bit windows 10 computer in the intelliJ IDE. I followed the steps in this tutorial in order to do so, and created an example program to see if the installation worked (see below).

import org.opencv.core.Core;

public class IsMyInstallBuggy {
    static {System.loadLibrary(Core.NATIVE_LIBRARY_NAME);}
    public static void main(String args[]) {
        System.out.println(Core.NATIVE_LIBRARY_NAME);
    }
}

I get this error when I try to run it:

"C:\Program Files\Java\jdk-10.0.1\bin\java.exe" -Djava.library.path=C:\Users\user\Desktop\opencv\build\java\x64 "- 
javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.1.5\lib\idea_rt.jar=50404:C:\Program 
Files\JetBrains\IntelliJ IDEA Community Edition 2018.1.5\bin" -Dfile.encoding=UTF-8 -classpath  
C:\Users\user\IdeaProjects\OpenCVThing\out\production\OpenCVThing;
C:\Users\user\Desktop\opencv\build\java\opencv-342.jar IsMyInstallBuggy
java.lang.UnsatisfiedLinkError: C:\Users\user\Desktop\opencv\build\java\x64\opencv_java342.dll: Can't find dependent libraries
    at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
    at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2424)
    at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2481)
    at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2678)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2643)
    at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:876)
    at java.base/java.lang.System.loadLibrary(System.java:1875)
    at IsMyInstallBuggy.<clinit>(IsMyInstallBuggy.java:5)
Exception in thread "main" 
Process finished with exit code 1

I've tried adding the location of the OpenCV .dll to the system path but it didn't change the error. I also tried redownloading the OpenCV win-pack and redoing the same process. I also have tried this process on other computers running multiple versions of 64 bit windows (7,8, and 10) and had them all work. I read in another post somewhere (I forget which one otherwise I would link it) that this error is due to the .dll being dependent on other .dlls that it can't find (this was in a custom OpenCV build though), but as an experiment, I tried running this program using the steps described in the tutorial with only the .jar and the .dll (no extra folders that come with the distribution) and it still worked. I have hit a wall with this problem and have no idea what to do. Any help would be greatly appreciated. Thank you! (I forgot to mention, I am using the latest edition of intellij community edition)

click to hide/show revision 2
retagged

updated 2018-08-18 22:41:11 -0600

berak gravatar image

Installation Problem: "can't find dependent libraries"

I was recently trying to install OpenCV (the java distribution) on a 64 bit windows 10 computer in the intelliJ IDE. I followed the steps in this tutorial in order to do so, and created an example program to see if the installation worked (see below).

import org.opencv.core.Core;

public class IsMyInstallBuggy {
    static {System.loadLibrary(Core.NATIVE_LIBRARY_NAME);}
    public static void main(String args[]) {
        System.out.println(Core.NATIVE_LIBRARY_NAME);
    }
}

I get this error when I try to run it:

"C:\Program Files\Java\jdk-10.0.1\bin\java.exe" -Djava.library.path=C:\Users\user\Desktop\opencv\build\java\x64 "- 
javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.1.5\lib\idea_rt.jar=50404:C:\Program 
Files\JetBrains\IntelliJ IDEA Community Edition 2018.1.5\bin" -Dfile.encoding=UTF-8 -classpath  
C:\Users\user\IdeaProjects\OpenCVThing\out\production\OpenCVThing;
C:\Users\user\Desktop\opencv\build\java\opencv-342.jar IsMyInstallBuggy
java.lang.UnsatisfiedLinkError: C:\Users\user\Desktop\opencv\build\java\x64\opencv_java342.dll: Can't find dependent libraries
    at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
    at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2424)
    at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2481)
    at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2678)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2643)
    at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:876)
    at java.base/java.lang.System.loadLibrary(System.java:1875)
    at IsMyInstallBuggy.<clinit>(IsMyInstallBuggy.java:5)
Exception in thread "main" 
Process finished with exit code 1

I've tried adding the location of the OpenCV .dll to the system path but it didn't change the error. I also tried redownloading the OpenCV win-pack and redoing the same process. I also have tried this process on other computers running multiple versions of 64 bit windows (7,8, and 10) and had them all work. I read in another post somewhere (I forget which one otherwise I would link it) that this error is due to the .dll being dependent on other .dlls that it can't find (this was in a custom OpenCV build though), but as an experiment, I tried running this program using the steps described in the tutorial with only the .jar and the .dll (no extra folders that come with the distribution) and it still worked. I have hit a wall with this problem and have no idea what to do. Any help would be greatly appreciated. Thank you! (I forgot to mention, I am using the latest edition of intellij community edition)