UnsatisfiedLinkError Java OpenCV 3.0.0
Dear all,
I just compiled Opencv-3.0.0 from the source code on Github with the following options: I'm running on Redhat 6.6.
mkdir build
cd build
cmake -D WITH_PTHREADS_PF=OFF -D WITH_OPENMP=ON -D WITH_IPP=OFF -DBUILD_SHARED_LIBS=OFF -D CMAKE_INSTALL_PREFIX=. ../
make -j8
Things seem to go well and the ant build also succeeds. In my build/lib directory I have a splendid 15 megabyte libopencv_java300.so, and in my build/bin directory a very lovely opencv-300.jar.
In order to test things out I've been using my Scala console. Here's the short program that I execute in the read-eval-print-loop:
[me@home lib]$ LD_LIBRARY_PATH=. scala -classpath ../bin/opencv-300.jar
Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_79).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import org.opencv.core._
import org.opencv.core._
scala> System.loadLibrary(Core.NATIVE_LIBRARY_NAME)
scala> new Rect(0,0,100,100)
res1: org.opencv.core.Rect = {0, 0, 100x100}
scala> new Scalar(10f)
res2: org.opencv.core.Scalar = [10.0, 0.0, 0.0, 0.0]
scala> new Mat(10,10, CvType.CV_32S)
java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat(III)J
at org.opencv.core.Mat.n_Mat(Native Method)
at org.opencv.core.Mat.<init>(Mat.java:37)
at .<init>(<console>:11)
at .<clinit>(<console>)
at .<init>(<console>:7)
at .<clinit>(<console>)
OpenCV 2.4.11 works wonderfully, but I was hoping to take advantage of a few of the improvements in 3.0.0, such as the new FeatureDescriptors and some of the improved Java API. Unfortunately, I haven't been able to get to the bottom of the UnsatisfiedLinkError. I would greatly appreciate any advice!
i'm having a similar issue with plain java,
Core.NATIVE_LIBRARY_NAME
resolves toopencv_java300
. so chances are high, that it did not find the so.(hackish) workaround:
System.load("/full/path/to/opencv_java300.so")
Hi Berak,
Thanks for the reply! I have been able to verify that the native loader is indeed finding the .so file. When I explicitly load the library with a System.load(...) call the result is still the same. It's very strange because it seems like Java is able to load the native library just fine, but subsequent method calls and object instantiations trigger the UnsatisfiedLinkError. I haven't had any trouble at all with OpenCV 2.4.11.
It's definitely possible (probable) that I just made a dumb-dumb error, but have you been able to load that .so and then instantiate either a Mat() or FeatureDetector()? It seems like there are a few more primitive-like classes such as Rect or Scalar that do not rely on native bindings.
I tried too and got error which says
I tried to load it through project file with hadoop from command prompt. Before this I have tried to load in eclipse there I face no issues.
Can anyone say what could be the issue.