Question

I'm sure this is going to be some sort of PATH Issue but i'm not sure where i'm going wrong. I am trying to get JavaCV working in my project in Eclipse so I can do some circle detection on images but get the following exception thrown by Eclipse when trying to run one of the sample projects:

java.lang.UnsatisfiedLinkError

I have tried to follow the instructions given at: http://code.google.com/p/javacv/

I have the javacv.jar and jna.jar in the BuildPath of my project. Wht do I need to do to add the correct files to the right paths to get JavaCV working?

I tried adding the jar files to $CLASSPATH but get the same error. I have downloaded and installed OpenCV, not sure what from this folder I need to add to $PATH. Any help is appreciated.

Was it helpful?

Solution

UnsatisfiedLink error mean that one or more native library files could not be linked into your program. This is most frequently caused by the native library files not being in the place where the JVM looks.

See section 2.7 of http://java.sun.com/docs/books/jni/html/start.html for more detail.

OTHER TIPS

Can you put the whole error that through in you application. Some times problem might be the incompatibility of the two versions of javacv and opencv. So try to check whether you have the compatible versions on those.

I also get the same exception when I try to run my first javacv application. I also try various things and last I found that the incompatible versions are the cause for this exception. So it might be the case in your problem as well.

I was also facing similar issue,i tried building OpenCV from source as well as using MacPorts. Than i tried setting the native library paths in eclipse to point to the location where OpenCV was built but this doesn't work for me. Finally i resolved the issue by installing OpenCV via Macports which installs all the .dylibs in "/opt/local/lib" path. Thereafter i executed the following shell script(given at http://code.google.com/p/javacv/wiki/HowToMakeAnApplet)

BADPATH=/opt/local/lib 
for f in libopencv*2.4.dylib; do install_name_tool $f -id @rpath/$f \
-add_rpath /usr/local/lib/ -add_rpath /opt/local/lib/ -add_rpath @loader_path/. \
-change $BADPATH/libopencv_core.2.4.dylib @rpath/libopencv_core.2.4.dylib \
-change $BADPATH/libopencv_calib3d.2.4.dylib @rpath/libopencv_calib3d.2.4.dylib \
-change $BADPATH/libopencv_features2d.2.4.dylib @rpath/libopencv_features2d.2.4.dylib \
-change $BADPATH/libopencv_flann.2.4.dylib @rpath/libopencv_flann.2.4.dylib \
-change $BADPATH/libopencv_gpu.2.4.dylib @rpath/libopencv_gpu.2.4.dylib \
-change $BADPATH/libopencv_highgui.2.4.dylib @rpath/libopencv_highgui.2.4.dylib \
-change $BADPATH/libopencv_imgproc.2.4.dylib @rpath/libopencv_imgproc.2.4.dylib \
-change $BADPATH/libopencv_legacy.2.4.dylib @rpath/libopencv_legacy.2.4.dylib \
-change $BADPATH/libopencv_ml.2.4.dylib @rpath/libopencv_ml.2.4.dylib \
-change $BADPATH/libopencv_nonfree.2.4.dylib @rpath/libopencv_nonfree.2.4.dylib \
-change $BADPATH/libopencv_objdetect.2.4.dylib @rpath/libopencv_objdetect.2.4.dylib \
-change $BADPATH/libopencv_photo.2.4.dylib @rpath/libopencv_photo.2.4.dylib \
-change $BADPATH/libopencv_video.2.4.dylib @rpath/libopencv_video.2.4.dylib; done

After running the above given script I simply created a sample JavaCV project(used the sample code given at http://www.cnblogs.com/ljsspace/archive/2011/08/05/2128948.html) and was able to run it successfully from eclipse without setting any other paths.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top