bytedeco / javacpp-presets

The missing Java distribution of native C++ libraries
Other
2.68k stars 744 forks source link

Issue - [Widows] java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path #670

Closed VirajAttanayake closed 5 years ago

VirajAttanayake commented 5 years ago

Hi

I'm getting above subject error when running my code in Windows10 (64x).

I followed the instructions in "Debugging UnsatisfiedLinkError on Windows" as stated but I get following error when inserted that code.

Exception in thread "main" java.lang.NullPointerException at org.bytedeco.javacpp.Loader.cacheResource(Loader.java:374) at org.bytedeco.javacpp.Loader.cacheResource(Loader.java:356) at org.bytedeco.javacpp.Loader.cacheResource(Loader.java:323) at lk.facesabotage.facedetector.FaceAligner.(FaceAligner.java:66) at lk.facesabotage.StartApp.main(StartApp.java:32)

Null Pointer is thrown in marked line

Null pointer code - String path = Loader.cacheResource(opencv_core.class, "windows-x86_64/jniopencv_core.dll").getPath();

    try {
        Loader.load(opencv_core.class);
    } catch (UnsatisfiedLinkError e) {
    String path = Loader.cacheResource(opencv_core.class, "windows-x86_64/jniopencv_core.dll").getPath();
        new ProcessBuilder("G:\\opencv343\\opencv\\build\\java\\x64\\DependenciesGui.exe", path).start().waitFor();
    }

Original Error

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1258) at org.bytedeco.javacpp.Loader.load(Loader.java:999) at org.bytedeco.javacpp.Loader.load(Loader.java:891) at org.bytedeco.javacpp.opencv_core.(opencv_core.java:10) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.bytedeco.javacpp.Loader.load(Loader.java:950) at org.bytedeco.javacpp.Loader.load(Loader.java:891) at org.bytedeco.javacpp.flandmark.(flandmark.java:13) at lk.facesabotage.facedetector.FaceLandMark.(FaceLandMark.java:31) at lk.facesabotage.facedetector.FaceAligner.(FaceAligner.java:69) at lk.facesabotage.StartApp.main(StartApp.java:32) Caused by: java.lang.UnsatisfiedLinkError: no opencv_imgproc343 in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1258) at org.bytedeco.javacpp.Loader.load(Loader.java:977) ... 10 more

Other Details This is a manually build project and following jars in eclipes build path

javacpp.jar flandmark-1.07-1.4.3.jar opencv-3.4.3-1.4.3.jar commons-math3-3.6.1.jar javacv-1.4.3.jar G:\opencv343\opencv\build\java\opencv-343.jar artoolkitplus-2.3.1-1.4.3.jar ffmpeg-4.0.2-1.4.3.jar flycapture-2.11.3.121-1.4.3.jar leptonica-1.76.0-1.4.3.jar libdc1394-2.2.5-1.4.3.jar libfreenect-0.5.3-1.4.3.jar libfreenect2-0.2.0-1.4.3.jar librealsense-1.12.1-1.4.3.jar tesseract-4.0.0-rc2-1.4.3.jar videoinput-0.200-1.4.3.jar

In addition opencv_java343.dll is in native Library location. I have also used System.loadLibrary(Core.NATIVE_LIBRARY_NAME); since I use pure opencv343 in same code. VM param is set to - -Djavacpp.platform.dependencies=true

Best Regards Viraj

saudet commented 5 years ago

Please try again with OpenCV 4.0.1! A lot has changed and this is probably fixed.

VirajAttanayake commented 5 years ago

Hi Saudet,

Thank you for the quick responce, still the same null pointer issue when added the dependency code and run with opencv 401. Kindly note that I upgrade to JavaCPP 1.4.4 and other libs are also updated as follows.(In addition opencv_java401.dll is in native Library location.)

image

Please help !!!

Regards Viraj

saudet commented 5 years ago

You'll need to add at least the JAR files with "windows" in their names. Please follow the instructions in the README.md file: https://github.com/bytedeco/javacpp-presets#manual-installation

VirajAttanayake commented 5 years ago

Again Thanks for the Quick Response. Thanks it worked when I put the windows jars

image