Ask Your Question
0

ROS Cmake won't see boost library

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

George B. gravatar image

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

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 -0600

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 -0600

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

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

Seen: 3,049 times

Last updated: Mar 28 '12