Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

So the workaround I found was to add

LINK_DIRECTORIES(/home/kir1pal/svslocal/lib)

BEFORE rosbuild_init() in my CMakeLists.txt

I found this out by first looking at my gcc line:

/usr/bin/c++   -O2 -g     -pthread CMakeFiles/main.dir/src/main.cpp.o  -o ../bin/main -rdynamic -L/home/kir1pal/svslocal/lib -L/opt/ros/groovy/lib -lroscpp -l:/usr/lib/libboost_signals-mt.so -l:/usr/lib/libboost_filesystem-mt.so -lrosconsole -l:/usr/lib/libboost_regex-mt.so -l:/usr/lib/liblog4cxx.so -lxmlrpcpp -lroscpp_serialization -lrostime -l:/usr/lib/libboost_date_time-mt.so -l:/usr/lib/libboost_system-mt.so -l:/usr/lib/libboost_thread-mt.so -lpthread -lcpp_common /home/kir1pal/svslocal/lib/libopencv_calib3d.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_contrib.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_core.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_features2d.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_flann.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_gpu.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_highgui.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_imgproc.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_legacy.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_ml.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_nonfree.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_objdetect.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_photo.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_stitching.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_superres.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_video.so.2.4.6 /home/kir1pal/svslocal/lib/libopencv_videostab.so.2.4.6 -Wl,-rpath,/opt/ros/groovy/lib

At the end is -rpath,/opt/ros/groovy/lib, which seems to be set by cmake macro LINK_DIRECTORIES. This seemed the be the cause of the problem. /opt/ros/groovy/lib is added to LINK_DIRECTORIES by rosbuild_init() and therefore by calling LINK_DIRECTORIES before rosbuild_init() puts my library path in front of it.

This is not an ideal solution. If anyone has a better idea I would like to hear it