bytedeco / javacpp-presets

The missing Java distribution of native C++ libraries
Other
2.65k stars 736 forks source link

UnsatisfiedLinkError: no jniopencv_core in java.library.path #510

Closed ahmedaomda closed 6 years ago

ahmedaomda commented 6 years ago

I'm trying to use JavaCV on a desktop application using JavaFX on Intillj IDEA and using maven I included

Caused by: java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1122) at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1191) at org.bytedeco.javacpp.Loader.load(Loader.java:953) at org.bytedeco.javacpp.Loader.load(Loader.java:854) at org.bytedeco.javacpp.opencv_core.<clinit>(opencv_core.java:10) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.bytedeco.javacpp.Loader.load(Loader.java:913) at org.bytedeco.javacpp.Loader.load(Loader.java:854) at org.bytedeco.javacpp.helper.opencv_core$AbstractArray.<clinit>(opencv_core.java:109) at org.bytedeco.javacv.OpenCVFrameGrabber.<init>(OpenCVFrameGrabber.java:82) at e_guestbook.cameraTest.initialize(cameraTest.java:40) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097) at e_guestbook.Main.start(Main.java:19) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177) ... 1 more Caused by: java.lang.UnsatisfiedLinkError: no opencv_imgproc340 in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1122) at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1191) at org.bytedeco.javacpp.Loader.load(Loader.java:940) ... 27 more

saudet commented 6 years ago

Since you are using Maven, could also show me the pom.xml file that you are using?

ahmedaomda commented 6 years ago

IntelliJ doesn't create a pom file but I mentioned the libs I've added using maven option

saudet commented 6 years ago

Could you try on the command line with Maven and the sample pom.xml file to see if it works?

ahmedaomda commented 6 years ago
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>E_book</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependency>
        <groupId>org.bytedeco</groupId>
        <artifactId>javacv-platform</artifactId>
        <version>1.4</version>
    </dependency>

</project>
saudet commented 6 years ago

That works, use that.

ahmedaomda commented 6 years ago

I'm but It's not working

saudet commented 6 years ago

Ok, since you're on Windows, please let me know what Dependency Walker says: https://github.com/bytedeco/javacpp-presets/wiki/Debugging-UnsatisfiedLinkError-on-Windows

saudet commented 6 years ago

Actually, please try with the sample pom.xml file here: https://github.com/bytedeco/javacv/#sample-usage Your pom.xml file probably doesn't work.

ahmedaomda commented 6 years ago

This is the output of using Dependency Walker as the Loader.cacheResource() returns null getPath() gets null pointer exception

java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389) at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767) Caused by: java.lang.NullPointerException at org.bytedeco.javacpp.Loader.cacheResource(Loader.java:373) at org.bytedeco.javacpp.Loader.cacheResource(Loader.java:355) at org.bytedeco.javacpp.Loader.cacheResource(Loader.java:322) at e_guestbook.Main.main(Main.java:44) ... 11 more

saudet commented 6 years ago

Right, so like I said, you pom.xml file won't work. Try the sample one from the README.md file. That one works.

ahmedaomda commented 6 years ago

Is there any sample I can Clone with the libs included ?!

saudet commented 6 years ago

Sure, this one for example: https://github.com/bytedeco/sample-projects/tree/master/opencv-stitching

saudet commented 6 years ago

I've just updated that sample project to the latest version of OpenCV and ran

mvn compile exec:java -Dexec.args="panorama_image1.jpg panorama_image2.jpg"

on Windows and everything works perfectly, so please use that as starting point.

ahmedaomda commented 6 years ago

Can I use this dependencies to import javacv for windows ?

<dependencies>
        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>windows-x86_64-javacv-platform</artifactId>
            <version>windows-x86_64-1.4</version>
        </dependency>
    </dependencies>
saudet commented 6 years ago

No, that would be:

    <dependencies>
        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>javacv-platform</artifactId>
            <version>1.4</version>
        </dependency>
    </dependencies>

just like it says in the README.md file.