[ros-users] Linking to packages with shared libraries

Nicholas Butko nbutko at ucsd.edu
Tue Aug 24 18:42:40 UTC 2010


readelf does not exist on OSX. Instead I did: 


Granite:OpenCV_HelloWorld nick$ otool -L bin/OpenCV_HelloWorld 
bin/OpenCV_HelloWorld:
	libopencv_core.2.1.dylib (compatibility version 2.1.0, current version 2.1.1)
	libopencv_imgproc.2.1.dylib (compatibility version 2.1.0, current version 2.1.1)
	libopencv_highgui.2.1.dylib (compatibility version 2.1.0, current version 2.1.1)
	libopencv_ml.2.1.dylib (compatibility version 2.1.0, current version 2.1.1)
	libopencv_video.2.1.dylib (compatibility version 2.1.0, current version 2.1.1)
	libopencv_objdetect.2.1.dylib (compatibility version 2.1.0, current version 2.1.1)
	libopencv_features2d.2.1.dylib (compatibility version 2.1.0, current version 2.1.1)
	libopencv_calib3d.2.1.dylib (compatibility version 2.1.0, current version 2.1.1)
	libopencv_contrib.2.1.dylib (compatibility version 2.1.0, current version 2.1.1)
	libopencv_legacy.2.1.dylib (compatibility version 2.1.0, current version 2.1.1)
	/Users/nick/ros/ros/core/roscpp/lib/libros.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/libboost_signals-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
	/Users/nick/ros/ros/3rdparty/xmlrpcpp/lib/libXmlRpc.dylib (compatibility version 0.0.0, current version 0.0.0)
	/Users/nick/ros/ros/core/rosconsole/lib/librosconsole.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/libboost_thread-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/liblog4cxx.10.dylib (compatibility version 11.0.0, current version 11.0.0)
	/Users/nick/ros/ros/core/roslib/lib/libroslib.dylib (compatibility version 0.0.0, current version 0.0.0)
	/Users/nick/ros/ros/tools/rospack/lib/librospack.dylib (compatibility version 0.0.0, current version 0.0.0)
	/Users/nick/ros/ros/tools/rospack/lib/librosstack.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)

It seems like the absolute path information is getting lost for OSX opencv2 linking? 




For comparison, here is the roslib manifest, which seems to be working correctly: 

	<cpp cflags="-I${prefix}/include `rosboost-cfg --cflags`" lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib -lroslib"/>

And here is the opencv2 manifest, which doesn't: 

	<cpp cflags="-I${prefix}/opencv/include -I${prefix}/opencv/include/opencv" lflags="-L${prefix}/opencv/lib -Wl,-rpath,${prefix}/opencv/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_objdetect -lopencv_features2d -lopencv_calib3d -lopencv_contrib -lopencv_legacy"/>

They seem identical in all important respects? 



Here is the linking code being generated by CMake: 

Granite:OpenCV_HelloWorld nick$ cat build/CMakeFiles/OpenCV_HelloWorld.dir/link.txt 

/usr/bin/c++   -O2 -g -Wl,-search_paths_first -headerpad_max_install_names -Wl,-rpath,/Users/nick/ros/stacks/vision_opencv/opencv2/opencv/lib -Wl,-rpath,/Users/nick/ros/ros/core/roscpp/lib -Wl,-rpath,/Users/nick/ros/ros/3rdparty/xmlrpcpp/lib -Wl,-rpath,/Users/nick/ros/ros/core/rosconsole/lib -Wl,-rpath,/Users/nick/ros/ros/core/roslib/lib -Wl,-rpath,/Users/nick/ros/ros/tools/rospack/lib -Wl,-rpath,/Users/nick/ros/ros/tools/rospack/lib -pthread CMakeFiles/OpenCV_HelloWorld.dir/src/OpenCV_HelloWorld.o  -o ../bin/OpenCV_HelloWorld  -L/Users/nick/ros/stacks/vision_opencv/opencv2/opencv/lib -L/Users/nick/ros/ros/core/roscpp/lib -L/Users/nick/ros/ros/3rdparty/xmlrpcpp/lib -L/Users/nick/ros/ros/core/rosconsole/lib -L/Users/nick/ros/ros/core/roslib/lib -L/Users/nick/ros/ros/tools/rospack/lib -L/Users/nick/ros/ros/3rdparty/gtest/gtest/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_objdetect -lopencv_features2d -lopencv_calib3d -lopencv_contrib -lopencv_legacy -lros -lboost_signals-mt -lXmlRpc -lrosconsole -lboost_thread-mt -llog4cxx -lroslib -lrospack -lrosstack 


--Nick 


On Aug 24, 2010, at 11:19 AM, Josh Faust wrote:

> opencv2's manifest exports -Wl,-rpath,${prefix}/opencv/lib, so your binary's rpath should include the path to the opencv lib.  What does "readelf -d <your binary> | grep RPATH" output?
> 
> Josh
> 
> On Tue, Aug 24, 2010 at 7:23 AM, Nicholas Butko <nbutko at ucsd.edu> wrote:
> How do packages tell other packages to add them to the *runtime* dynamic library path?
> 
> I built the opencv2 package, and then made a package that depended on it. In the dependent package I made a simple HelloWorld that gets and displays images from the camera. Everything built correctly, but the binary wouldn't run because the shared library was not loaded.
> 
> I manually modified my global shared library path (in .bashrc) to include opencv2's lib directory, and then my program ran fine. But it would be better if I didn't have to manually hack my shared library path for every package with shared libraries.
> 
> Is there a good solution to this problem?
> 
> --Nick
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
> 
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20100824/4bd04f69/attachment-0003.html>


More information about the ros-users mailing list