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

rtt_ros_integration marshalling C++ linking

asked 2015-08-18 09:54:34 -0500

arennuit gravatar image

updated 2015-08-19 11:09:43 -0500

Hi all,

I am currently trying to follow the examples for orocos using the rtt_ros_integration package.

The examples were written for an old version of the rtt ros integration package hence I have to change a few things to get them working.

I have a problem with example hello 2 when trying to load the marshalling service into my component in C++, my compilation outputs the following problem:

CMakeFiles/hello-2-properties.dir/HelloWorld.cpp.o: In function `boost::shared_ptr<RTT::Marshalling> boost::dynamic_pointer_cast<RTT::Marshalling, RTT::ServiceRequester>(boost::shared_ptr<RTT::ServiceRequester> const&)':
/usr/include/boost/smart_ptr/shared_ptr.hpp:814: undefined reference to `typeinfo for RTT::Marshalling'
CMakeFiles/hello-2-properties.dir/HelloWorld.cpp.o: In function `boost::detail::sp_if_not_array<RTT::Marshalling>::type boost::make_shared<RTT::Marshalling, RTT::TaskContext*>(RTT::TaskContext* const&)':
/usr/include/boost/smart_ptr/make_shared_object.hpp:711: undefined reference to `RTT::Marshalling::Marshalling(RTT::TaskContext*)'
collect2: error: ld returned 1 exit status

It looks to me that my linker cannot find some definition it needs.

Now googling for the problem what I find is the answer for the problem, but for the old version of rtt ros integration. The solution being to add rtt-marshalling to find_package() and RTT-MARSHALLING_LIBRARYto target_link_libraries() in the CMakeLists.txt.

Obviously this no longer works.

Note that the marshalling works well when loaded from script.

Anyone has an idea?

Thanks,

Antoine.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-08-19 11:08:46 -0500

arennuit gravatar image

All right, I believe I have found the answer. I will explain it here as I do not find it obvious:

You should add RTT-MARSHALLING_LIBRARY to target_link_libraries in your CMakeLists.txt, right after ${OROCOS-RTT. Hence a basic working version of the CMakeLists.txt could look like:

cmake_minimum_required(VERSION 2.8.3)

project(hello-2-properties)

find_package(catkin REQUIRED COMPONENTS rtt_ros)

catkin_package(
  CATKIN_DEPENDS rtt_ros 
)

add_definitions(-DRTT_COMPONENT)
# Creates an orocos component HelloWorld
orocos_component(${PROJECT_NAME} HelloWorld.cpp) # ...you may add multiple source files
target_link_libraries(
    ${PROJECT_NAME}
    ${catkin_LIBRARIES}
    ${OROCOS-RTT_RTT-MARSHALLING_LIBRARY} 
    ${USE_OROCOS_LIBRARIES}
    )

# Makes this an installable/usable package for other packages.
orocos_generate_package()

Note that the very same problem arises when linking against the scripting service. To tackle with this, simply replace RTT-MARSHALLING_LIBRARY by RTT-SCRIPTING_LIBRARY in the above example.

Cheers,

Antoine.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-08-18 09:54:34 -0500

Seen: 290 times

Last updated: Aug 19 '15