[ros-users] OpenCL under OS X Leopard, dyld: Library not loaded

Julian Schmid schmidj at informatik.uni-freiburg.de
Sun Dec 12 19:10:16 UTC 2010


Hi,

I had a problem with OpenCL under OS X 10.6.5. Whenever I tried to 
rosrun a program that dependet on OpenCL I got the following error message:

rosrun image_view image_view
dyld: Library not loaded: libopencv_core.2.1.dylib
Referenced from: /Users/lazewatskyd/ros/stacks/image_pipeline/
image_view/bin/image_view
Reason: image not found

After some google research, I found out, that I was not the first person 
with that problem. Long story short, I found a script and modified it so 
that it would fix my problem.

In case someone else has the same problem do the following steps:

1) Save the script into a file and remember the path to it (in this 
example /path/to/mac_fix)
2) roscd into you opencv2 directory: roscd opencv2
3) Call the script: bash /path/to/mac_fix
4) Recompile the rospackages which depend on opencv

I hope this helps someone.

Greets
Julian

And here the modified script (original script is from the 
embedded-control-library 
http://embedded-control-library.googlecode.com/svn/trunk/ecl_vision/opencv_embedded./opencv 
):
--------------------------------------------


#! /bin/bash

# On Mac OSX, every dynamic library (*.dylib) has its own 'install name',
# and it is used for locating the actual library file at runtime.
# The install name shows up at the first line of the output of 'otool -L 
<name.dylib>'.
# When a program or a library is linked with other libraries, it copies
# all the install names of the other libraries, so that it can find them 
in run-time.
#
# For an unknown reason, in our customised OpenCV package, 
'opencv_embedded',
# the dynamic libraries do not have full path information in their 
install names.
# This results in the 'image not found' error at runtime.
# This script (only for Mac OSX) fixes this problem by changing the 
install names.


if [ "`uname`" == "Darwin" ]; then

     install_name_tool -id 
`pwd`/opencv/lib/libopencv_core.2.1.dylib      
opencv/lib/libopencv_core.2.1.dylib
     install_name_tool -id 
`pwd`/opencv/lib/libopencv_calib3d.2.1.dylib      
opencv/lib/libopencv_calib3d.2.1.dylib
     install_name_tool -id 
`pwd`/opencv/lib/libopencv_contrib.2.1.dylib      
opencv/lib/libopencv_contrib.2.1.dylib
     install_name_tool -id 
`pwd`/opencv/lib/libopencv_features2d.2.1.dylib      
opencv/lib/libopencv_features2d.2.1.dylib
     install_name_tool -id 
`pwd`/opencv/lib/libopencv_highgui.2.1.dylib      
opencv/lib/libopencv_highgui.2.1.dylib
     install_name_tool -id 
`pwd`/opencv/lib/libopencv_imgproc.2.1.dylib      
opencv/lib/libopencv_imgproc.2.1.dylib
     install_name_tool -id 
`pwd`/opencv/lib/libopencv_legacy.2.1.dylib      
opencv/lib/libopencv_legacy.2.1.dylib
     install_name_tool -id `pwd`/opencv/lib/libopencv_ml.2.1.dylib      
opencv/lib/libopencv_ml.2.1.dylib
     install_name_tool -id 
`pwd`/opencv/lib/libopencv_objdetect.2.1.dylib      
opencv/lib/libopencv_objdetect.2.1.dylib
     install_name_tool -id 
`pwd`/opencv/lib/libopencv_video.2.1.dylib      
opencv/lib/libopencv_video.2.1.dylib

     install_name_tool -change libopencv_core.2.1.dylib 
`pwd`/opencv/lib/libopencv_core.2.1.dylib 
opencv/lib/libopencv_core.2.1.dylib

     install_name_tool -change libopencv_calib3d.2.1.dylib 
`pwd`/opencv/lib/libopencv_calib3d.2.1.dylib 
opencv/lib/libopencv_calib3d.2.1.dylib
     install_name_tool -change libopencv_core.2.1.dylib 
`pwd`/opencv/lib/libopencv_core.2.1.dylib 
opencv/lib/libopencv_calib3d.2.1.dylib
     install_name_tool -change libopencv_imgproc.2.1.dylib 
`pwd`/opencv/lib/libopencv_imgproc.2.1.dylib 
opencv/lib/libopencv_calib3d.2.1.dylib

     install_name_tool -change libopencv_contrib.2.1.dylib 
`pwd`/opencv/lib/libopencv_contrib.2.1.dylib 
opencv/lib/libopencv_contrib.2.1.dylib
     install_name_tool -change libopencv_core.2.1.dylib 
`pwd`/opencv/lib/libopencv_core.2.1.dylib 
opencv/lib/libopencv_contrib.2.1.dylib
     install_name_tool -change libopencv_imgproc.2.1.dylib 
`pwd`/opencv/lib/libopencv_imgproc.2.1.dylib 
opencv/lib/libopencv_contrib.2.1.dylib
     install_name_tool -change libopencv_calib3d.2.1.dylib 
`pwd`/opencv/lib/libopencv_calib3d.2.1.dylib 
opencv/lib/libopencv_contrib.2.1.dylib
     install_name_tool -change libopencv_features2d.2.1.dylib 
`pwd`/opencv/lib/libopencv_features2d.2.1.dylib 
opencv/lib/libopencv_contrib.2.1.dylib
     install_name_tool -change libopencv_highgui.2.1.dylib 
`pwd`/opencv/lib/libopencv_highgui.2.1.dylib 
opencv/lib/libopencv_contrib.2.1.dylib
     install_name_tool -change libopencv_ml.2.1.dylib 
`pwd`/opencv/lib/libopencv_ml.2.1.dylib 
opencv/lib/libopencv_contrib.2.1.dylib
     install_name_tool -change libopencv_video.2.1.dylib 
`pwd`/opencv/lib/libopencv_video.2.1.dylib 
opencv/lib/libopencv_contrib.2.1.dylib
     install_name_tool -change libopencv_objdetect.2.1.dylib 
`pwd`/opencv/lib/libopencv_objdetect.2.1.dylib 
opencv/lib/libopencv_contrib.2.1.dylib

     install_name_tool -change libopencv_features2d.2.1.dylib 
`pwd`/opencv/lib/libopencv_features2d.2.1.dylib 
opencv/lib/libopencv_features2d.2.1.dylib
     install_name_tool -change libopencv_core.2.1.dylib 
`pwd`/opencv/lib/libopencv_core.2.1.dylib 
opencv/lib/libopencv_features2d.2.1.dylib
     install_name_tool -change libopencv_imgproc.2.1.dylib 
`pwd`/opencv/lib/libopencv_imgproc.2.1.dylib 
opencv/lib/libopencv_features2d.2.1.dylib
     install_name_tool -change libopencv_calib3d.2.1.dylib 
`pwd`/opencv/lib/libopencv_calib3d.2.1.dylib 
opencv/lib/libopencv_features2d.2.1.dylib
     install_name_tool -change libopencv_highgui.2.1.dylib 
`pwd`/opencv/lib/libopencv_highgui.2.1.dylib 
opencv/lib/libopencv_features2d.2.1.dylib

     install_name_tool -change libopencv_highgui.2.1.dylib 
`pwd`/opencv/lib/libopencv_highgui.2.1.dylib 
opencv/lib/libopencv_highgui.2.1.dylib
     install_name_tool -change libopencv_core.2.1.dylib 
`pwd`/opencv/lib/libopencv_core.2.1.dylib 
opencv/lib/libopencv_highgui.2.1.dylib
     install_name_tool -change libopencv_imgproc.2.1.dylib 
`pwd`/opencv/lib/libopencv_imgproc.2.1.dylib 
opencv/lib/libopencv_highgui.2.1.dylib

     install_name_tool -change libopencv_imgproc.2.1.dylib 
`pwd`/opencv/lib/libopencv_imgproc.2.1.dylib 
opencv/lib/libopencv_imgproc.2.1.dylib
     install_name_tool -change libopencv_core.2.1.dylib 
`pwd`/opencv/lib/libopencv_core.2.1.dylib 
opencv/lib/libopencv_imgproc.2.1.dylib

     install_name_tool -change libopencv_legacy.2.1.dylib 
`pwd`/opencv/lib/libopencv_legacy.2.1.dylib 
opencv/lib/libopencv_legacy.2.1.dylib
     install_name_tool -change libopencv_core.2.1.dylib 
`pwd`/opencv/lib/libopencv_core.2.1.dylib 
opencv/lib/libopencv_legacy.2.1.dylib
     install_name_tool -change libopencv_imgproc.2.1.dylib 
`pwd`/opencv/lib/libopencv_imgproc.2.1.dylib 
opencv/lib/libopencv_legacy.2.1.dylib
     install_name_tool -change libopencv_calib3d.2.1.dylib 
`pwd`/opencv/lib/libopencv_calib3d.2.1.dylib 
opencv/lib/libopencv_legacy.2.1.dylib
     install_name_tool -change libopencv_features2d.2.1.dylib 
`pwd`/opencv/lib/libopencv_features2d.2.1.dylib 
opencv/lib/libopencv_legacy.2.1.dylib
     install_name_tool -change libopencv_highgui.2.1.dylib 
`pwd`/opencv/lib/libopencv_highgui.2.1.dylib 
opencv/lib/libopencv_legacy.2.1.dylib
     install_name_tool -change libopencv_video.2.1.dylib 
`pwd`/opencv/lib/libopencv_video.2.1.dylib 
opencv/lib/libopencv_legacy.2.1.dylib

     install_name_tool -change libopencv_ml.2.1.dylib 
`pwd`/opencv/lib/libopencv_ml.2.1.dylib opencv/lib/libopencv_ml.2.1.dylib
     install_name_tool -change libopencv_core.2.1.dylib 
`pwd`/opencv/lib/libopencv_core.2.1.dylib opencv/lib/libopencv_ml.2.1.dylib

     install_name_tool -change libopencv_objdetect.2.1.dylib 
`pwd`/opencv/lib/libopencv_objdetect.2.1.dylib 
opencv/lib/libopencv_objdetect.2.1.dylib
     install_name_tool -change libopencv_core.2.1.dylib 
`pwd`/opencv/lib/libopencv_core.2.1.dylib 
opencv/lib/libopencv_objdetect.2.1.dylib
     install_name_tool -change libopencv_imgproc.2.1.dylib 
`pwd`/opencv/lib/libopencv_imgproc.2.1.dylib 
opencv/lib/libopencv_objdetect.2.1.dylib

     install_name_tool -change libopencv_video.2.1.dylib 
`pwd`/opencv/lib/libopencv_video.2.1.dylib 
opencv/lib/libopencv_video.2.1.dylib
     install_name_tool -change libopencv_core.2.1.dylib 
`pwd`/opencv/lib/libopencv_core.2.1.dylib 
opencv/lib/libopencv_video.2.1.dylib
     install_name_tool -change libopencv_imgproc.2.1.dylib 
`pwd`/opencv/lib/libopencv_imgproc.2.1.dylib 
opencv/lib/libopencv_video.2.1.dylib


     echo "Install names have been changed in opencv/lib/*.dylib files"
fi





More information about the ros-users mailing list