我也面临类似的问题,我尝试从源代码构建 OpenCV 以及使用 MacPorts。比我尝试在 eclipse 中设置本机库路径以指向构建 OpenCV 的位置,但这对我不起作用。最后,我通过 Macports 安装 OpenCV 解决了这个问题,Macports 将所有 .dylibs 安装在“/opt/local/lib”路径中。此后我执行了以下 shell 脚本(在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
运行上面给定的脚本后,我简单地创建了一个示例 JavaCV 项目(使用http://www.cnblogs.com/ljsspace/archive/2011/08/05/2128948.html给出的示例代码)并能够运行它从 Eclipse 成功,无需设置任何其他路径。