ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ROS Cmake won't see boost library

asked 2012-03-28 01:16:26 -0500

George B. gravatar image

updated 2014-01-28 17:11:46 -0500

ngrennan gravatar image

Hello, I am currently writing a cpp in my ROS package based on this tutorial but there seems to be a linking error as the boost::filesystem classes aren't recognized.

I've searched for an answer on the Internet and only found the suggestion to add #define BOOST_FILESYSTEM_VERSION 2 after the #include for boost,which unfortunately doesn't help and there were also suggestions of explicitly linking to boost_system in my CMakeLists.txt but since I've only started using cmake since I've begun ROS I don't know to do much beyond adding executables.

I am working on Ubuntu 11.10 the boost libraries include with it are 1.46.1 and I am working with ROS electric and I feel the need to mention that I've used boost shared pointers in this package before without needing to add any includes or dependencies.

Any answers on what I need to add to my CMakeList.txt, if that is where I need to work, would be greatly appreciated.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-03-28 03:08:35 -0500

Miguel Prada gravatar image

I believe you need to first add

rosbuild_add_boost_directories()

And then link against the library you want to use with

rosbuild_link_boost(target lib1 lib2 lib3 ...)

You were probably able to use shared pointers because the boost lib that includes those is header only and there's no need to link with anything.

edit flag offensive delete link more
0

answered 2012-03-28 03:59:13 -0500

George B. gravatar image

Thank you, yes in the end it was a linking error but I ultimately went with this in my CMakeList.txt :

target_link_libraries(my_cpp ${PROJECT_NAME} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} )
edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-03-28 01:16:26 -0500

Seen: 3,493 times

Last updated: Mar 28 '12