UnsatisfiedLinkError: no opencv_java249 in java.library.path

后端 未结 9 1434
旧巷少年郎
旧巷少年郎 2020-11-27 05:38

Running into some problems making a piece of code run on my mac. Had someone write me an image analysis java app but I keep getting this error when trying to run it on netbe

相关标签:
9条回答
  • 2020-11-27 06:15

    You cannot just put Windows library (dll file) on Mac and have it running - you need to compile the library for Mac first (or get Mac version of the library).

    Please see here for tips on how to do it:

    .dll Equivalent on Mac OS X

    How do third-party libraries work in Objective-C and Xcode?

    How to use a Windows DLL with Java in Mac OS X?

    0 讨论(0)
  • 2020-11-27 06:16

    Look into your OpenCV directory;

    For an example this; (installed using brew install opencv3 --with-java --with-python3)

    /usr/local/Cellar/opencv3/XXX/share/OpenCV/java
    

    You will see;

    libopencv_javaXXX.so    opencv-XXX.jar
    

    Now that you already have OpenCV's native library for Java (libopencv_javaXXX.so) compiled with you, the only thing left is, mac's dynamic library.

    Link libopencv_javaXXX.so to libopencv_javaXXX.dylib;

    ln -s libopencv_javaXXX.so libopencv_javaXXX.dylib
    

    Now add /usr/local/Cellar/opencv3/XXX/share/OpenCV/java as Native Library Locations in IntelliJ or something similar in Eclipse.

    Or add this to your JVM arguments;

    -Djava.library.path=/usr/local/Cellar/opencv3/XXX/share/OpenCV/java
    
    0 讨论(0)
  • 2020-11-27 06:21

    Instead of struggling with manual installation of OpenCV libraries I suggest you use OpenCV Java library packaged by OpenPnP (https://github.com/openpnp/opencv) that includes all required DLL.

    It does not require additonal steps except of adding it to your build automation tool configuration (Gradle in my case) and adding the following code to load the library:

     System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
    
    0 讨论(0)
提交回复
热议问题