linking a library exported by another ROS package [closed]

asked 2013-08-05 00:06:59 -0500

kid-a gravatar image

updated 2013-08-05 03:28:39 -0500

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:

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

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
Linking CXX executable ../bin/tests
CMakeFiles/tests.dir/test/tests.o: In function `GaussianMixtureModels_depthInverseModel2W_Test::TestBody()':
/home/loris/spa_depth_model/test/ 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/
target_link_libraries(tests ${PROJECT_NAME} ros_mathlib)

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

I believe there's something wrong in my current understanding of how to link against other packages in ROS, and I'd be glad to hear from you on this.

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2016-04-27 02:00:13.468993