OpenCV Java Ubuntu UnsatisfiedLinkError
I installed Oracle Java from WebUpd8 and am trying to get OpenCV working according to these instructions.
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install -y oracle-java7-installer oracle-java7-set-default build-essential cmake
$ sudo update-java-alternatives -s java-7-oracle
$ cd opencv/build
$ cmake -DBUILD_SHARED_LIBS=OFF ..
$ make
$ scala -cp /home/parallels/opencv/build/bin/opencv-248.jar -Djava.library.path=/home/parallels/opencv/build/lib
scala> import org.opencv.core._
scala> System.loadLibrary(Core.NATIVE_LIBRARY_NAME)
scala> val m:Mat = Mat.eye(3,3,CvType.CV_8UC1)
As far as I can tell, this is correct, but I keep running into the following error:
java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J
at org.opencv.core.Mat.n_eye(Native Method)
at org.opencv.core.Mat.eye(Mat.java:1467)
at .<init>(<console>:10)
at .<clinit>(<console>)
at .<init>(<console>:11)
at .<clinit>(<console>)
at $print(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
at scala.tools.nsc.interpreter.IMain$Request$$anonfun$14.apply(IMain.scala:920)
at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
at java.lang.Thread.run(Thread.java:744)
What could be causing this? How do I remedy this?
I got this error in opencv android also and I discovered that I must create all my instances after I receive some callback from opencv. I used the onCameraPreview(not sure if this is this the correct name). It probably has something to do with multi-threading, meaning it's possible that Opencv lib isn't initialized by the time you are making the call to create the instance (not sure if this is the case, I am just guessing). Hope it helps.
I'm seeing the same thing on 2.4.9.0 with scala 2.11.
I did manage to get compiled code to load it, however:
But not in the repl :(.
Hmm - you could try loading the dll/so directly with an absolute path - for tracking down the problem