Java Link error when compiling from console (2.4.9)

asked 2015-02-27 13:21:00 -0600

Miguel Lorenzo gravatar image

Hi, when I try to compile and run a basic java program using openCV I get Link errors, however it compiles just fine. I've added opencv_java249.dll to my jre/bin folder, and opencv-249.jar to jre/lib/ext. My java version is 1.8.0_31 I can run java programs using openCV with eclipse without problems, importing the library as suggested in the documentation. The folder in which my source code is, contains also the opencv_java249.dll (although i really ignore if that helps)

import org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.core.MatOfRect; import org.opencv.core.Point; import org.opencv.core.Rect; import org.opencv.core.Scalar;

public class Test {

public static void main(String[] args) {
    System.loadLibrary("opencv_java249");
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

            Mat mm = new Mat();
}

}

When running, the exception I get is:

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat()J at org.opencv.core.Mat.n_Mat(Native Method) at org.opencv.core.Mat.<init>(Mat.java:447) at Test.main(Test.java:18)

Exceptions also happen if I try to access another Class, such as CascadeClassifier, so it is really a linker problem.

I hope someone can help.

Mike

edit retag flag offensive close merge delete

Comments

did you try doing it the ant way ? http://docs.opencv.org/doc/tutorials/...

berak gravatar imageberak ( 2015-02-27 13:27:18 -0600 )edit

I haven't, however when I want to add external jar's and dll's i've done that and it's worked. I did the same thing with Jinput ( access to joysticks) and rtxSerial (serial comm). And I can run those projects from the command line. I wonder what the difference is between OpenCV java implementation and any other library.

Miguel Lorenzo gravatar imageMiguel Lorenzo ( 2015-02-27 19:30:39 -0600 )edit