Ask Your Question
0

Java program Opencv unsatisfiedlinkerror

asked 2016-01-14 10:52:30 -0600

I have a java application designed to run in the Linux environment, developed using Opencv and Eclipse - Ubuntu 14.04. It runs fine inside Eclipse and produces a .jar on export. The program .jar works perfectly on the system where the opencv is installed.

java -Dpath.java.library="/home/me" -jar program.jar

The library where opencv is installed has all the so files and links to so files in place and when I do a ldd on the libopencv_java310.so it displays all the associated so files/links are aokay.

However on the machine where opencv is not installed:

I have been able to carry the libs over and create all the links using the ln command however I am still getting java.lang.unsatifiedlinkerror: /my/lib/libopencv_java310.so: libopencv_core.so.3.1: cannot open shared object file: No such file or directory

I did an ldd on libopencv_java310.so and the result is libopencv_core.so.3.1 => not found - one of several not founds in the opencv library.

The link libopencv_core.so.3.1 is in the directory along with all the other correct link files and their corresponding so files. What am I missing here? I know I need get the libopencv_java310.so to find the links but I don't know how.

The end point of this exercise is to make either a self contained executable, .jar or a combination of lib files and .jar to be distributed to end user in the linux environment.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-01-16 18:36:47 -0600

The answer is the Opencv libraries need to be stored on the installation machine in exactly the same directories as the production machine. In my case, I may have not used the right directories during my initial installation on the production machine - storing the opencv libraries in my workspace.

First, I created the same directories on the installation PC /home/me/OpenCV/opencv-3.1.0/build/lib and copied all the opencv libraries from the production machine into that directory.

Second, I used ldd /home/me/opencv_java310.so to find the libraries with missing links.

Third, I used ln -s library.file library.link name to create each link as named in the ldd output.

Fourth, I had to copy over and create links for some libraries stored in the system area /usr/lib and /usr/lib/x86_64-linux-gnu that were also highlighted as missing in the ldd output from opencv_java310.so

Finally, I was able to execute the program java -Djava.library.path="/home/me/OpenCv/opencv-3.1.0/build/lib" -jar program.jar

My next step will be to automate this process with either a shell or some other utility and zip files to contain all the data. I suspect that I should carry ALL the library files from the ldd opencv_java310.so output and create the links just in case the installation machine does not have any of them.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-01-14 10:52:30 -0600

Seen: 805 times

Last updated: Jan 16 '16