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
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?
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
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);