Ask Your Question
0

Installation Problem: "can't find dependent libraries"

asked 2018-07-18 00:19:08 -0600

Faraday gravatar image

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

berak gravatar image

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)

edit retag flag offensive close merge delete

Comments

I've tried adding the location of the OpenCV .dll to the system path but it didn't change the error.

yes, that's what you have to do. however, most likely you have to restart (at least) your ide, so it can read the updated environment.

berak gravatar imageberak ( 2018-07-18 00:26:30 -0600 )edit

@berak I just tried it again, this time restarting both IntelliJ and the entire computer with no success. The error didn't change.

Faraday gravatar imageFaraday ( 2018-07-19 13:58:41 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
-2

answered 2018-08-18 20:25:36 -0600

Pehr gravatar image

First time I tried to use openCV today and I had the same issue. Eventually I switched version; from 3.4.2 to 2.4.13.6 and that worked fine, but I needed some of the things from 3.x so I ended up going with 3.3.1.

So... why doesn't 3.4.2 work for us? Pretty much all .dll files have dependencies. If you want to find out what they are, Visual Studio comes with a nice little command tool - dumpbin. If you use it on 3.3.1 you get the following:

Dump of file opencv_java331.dll

File Type: DLL

Image has the following dependencies:

MSVFW32.dll
AVIFIL32.dll
AVICAP32.dll
KERNEL32.dll
USER32.dll
GDI32.dll
ole32.dll
OLEAUT32.dll
COMDLG32.dll
ADVAPI32.dll

I have all those dll files in my windows\system32 folder. If you run dumpbin on 3.4.2, the dependencies has changed and several of those dll files are not on my system.

Dump of file opencv_java342.dll

File Type: DLL

Image has the following dependencies:

MSVFW32.dll
AVIFIL32.dll
AVICAP32.dll
ole32.dll
KERNEL32.dll
USER32.dll
OLEAUT32.dll
MFPlat.DLL
MF.dll
MFReadWrite.dll
d3d11.dll
api-ms-win-downlevel-shlwapi-l1-1-0.dll

So try an older version. If you really need to use 3.4.2, you need to get hold of all those dll files. Good luck.

edit flag offensive delete link more

Comments

1

sorry, but this is entire BS.

berak gravatar imageberak ( 2018-08-18 23:05:11 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-07-18 00:19:08 -0600

Seen: 4,443 times

Last updated: Aug 18 '18