7

When loading the library in my main src folder there is no problem, but in the test src folder I get the error. I can still compile and run all the tests normally and they pass.

Both src folder are in the path and I got opencv as a library. Like I said, everything is working, so I guess it's a problem with Eclipse and the display of the error which should not be displayed? So the main problem is that it's visually a pain.

enter image description here

enter image description here

EDIT2 : I just want to say again that everything is working, the tests are all running, it is simply that they pop as problems (and I don't see the errors of the tests because this unspecifiedlinkerror is before and overshadow them)

Also, it does the same thing on both my Windows and Ubuntu machine.

my path is also correct when I print it out right before the System.loadLibrary as .../opencv-2.4.11/build/lib

EDIT3 : I tried Cibin William answer and put my .dll path but to no avail

enter image description here

3 Answers 3

2

You can right on the project and click on Build Path -> Configure Build Path -> then select the Libraries tab and select OpenCV jar file and then expend it and then select on Native Library Location and then click on the Edit and then brows the to the .dll file of OpenCV something like this C:\opencv\build\java\x64 Or C:\opencv\build\java\x86 for 32bit System. And it is that.

Or You can load the library by coding (dynamically)

public static void loadOpenCV_Lib() throws Exception {
    // get the model
    String model = System.getProperty("sun.arch.data.model");
    // the path the .dll lib location
    String libraryPath = "C:/opencv/build/java/x86/";
    // check if system is 64 or 32
    if(model.equals("64")) {
        libraryPath = "C:/opencv/build/java/x64/";
    }
    // set the path
    System.setProperty("java.library.path", libraryPath);
    Field sysPath = ClassLoader.class.getDeclaredField("sys_paths");
    sysPath.setAccessible(true);
    sysPath.set(null, null);
    // load the lib
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
}
Sign up to request clarification or add additional context in comments.

2 Comments

I've done that and updated my question with a picture of it.
It is the only two ways that can link the lib to the project. You can try to restart the eclipse. Hope it works
0

When I run the OpenCV program in eclipse ,unsatisfiedLInkError occurs.I solve the error by exporting the library path in eclipse as follows

1.Right click on the project,seleect Debug as->Debug Configurations...

2.Debug Configuration window appears,Select the Environment tab in the top

3.Click the New button on the right side of the window,A New Environment Variable window appears

4.On the Name type LD_LIBRARY_PATH and in the Value type the folder which contain the .dll file(If the .dll is present in the Lib folder inside the project,type Lib in the Value)

Please try and reply.....

1 Comment

@Benoit ,same error?Whether you tried ,copy the .dll to the project path or create a folder inside the project and add the .dll,add that folder path as i described above...
0

Well, I reinstalled Eclipse and that did it...sigh

The bug was on both Eclipse Luna and Mars Version 4.5.1.

Mars Version 4.5.2 is working fine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.