linking a library exported by another ROS package [closed]

Hi there,

I have two ROS packages, ros_mathlib and spa_depth_model.
Both of them are written in C++ and export shared objects (.so).
The latter depends on the former, that is spa_depth_model makes use of classes implemented by ros_mathlib.

Following the documentation, I added the following lines to the manifest file of ros_mathlib:

<export>
<cpp cflags="-I${prefix}/include" lflags="-L${prefix}/lib -Wl,-rpath,${prefix}/lib"/> </export>  while the manifest of spa_depth_model simply states its dependency on ros_mathlib: ... <depend package="ros_mathlib"/> ...  Now, building ros_depth_model works fine (a shared object is produced, so ros_mathlib is not actually linked). However, building its tests results in a linking error: $ make tests
...
CMakeFiles/tests.dir/test/tests.o: In function GaussianMixtureModels_depthInverseModel2W_Test::TestBody()':
/home/loris/spa_depth_model/test/tests.cc:186: undefined reference to Vector::undef'


If I explicitly specify the dependence of the test on ros_mathlib in the CMakelists.txt file, the error goes away:

rosbuild_add_gtest(tests test/tests.cc)

However, editing CMakelists.txt seems not to be the recommended way to link against libraries exported by other ROS packages.