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

Link error: undefined constructor for ROSType

asked 2018-12-13 20:20:44 -0600

johna gravatar image

I'm trying to build a node based on Davide Faconti's ros_type_introspection example. Everything compiles fine, and there are no issues linking against most of the ros_type_introspection stuff.

The example contains the following:

const std::string&  datatype   =  msg->getDataType();
const std::string&  definition =  msg->getMessageDefinition();

// don't worry if you do this more than once: already registered message are not overwritten.
parser.registerMessageDefinition( topic_name,
                                  definition );

This attempts to create a ROSType object, passing in datatype, reference to a string. This produces the following linker error:

undefined reference to 'RosIntrospection::ROSType::ROSType(std::basic_string_view<char, std::char_traits<char> >)'

Note that the compiler has produced a reference to a ROSType constructor taking a std::string_view rather than a std::string. The header file has that constructor declared as:

 ROSType(absl::string_view name);

In abseil's string_view.h, there's code to conditionally use std::string_view (I'm compiling as C++17), so it's pretty clear why the compiler is doing what it's doing. The question is why the library does not agree. Presumably it was built in an environment where std::string_view was not available, so presumably that constructor has a different signature (i.e. taking absl::string_view instead).

Can anyone suggest a way to get around this?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-12-13 22:24:38 -0600

ahendrix gravatar image

I'd suggest making sure that your package and ros_type_introspection are all built with the same C++ version. The easiest way to do that may be to clone the ros_type_introspection package into your workspace and adjust it to build in C++17 mode.

edit flag offensive delete link more

answered 2019-01-18 03:24:37 -0600

Davide Faconti gravatar image


it might be indeed a problem of binary compatibility as @ahendrix pointed out. Please report this kind of issues and a way to reproduce them on Guthub, and I will try to fix them if I can.


edit flag offensive delete link more

Question Tools



Asked: 2018-12-13 20:20:44 -0600

Seen: 317 times

Last updated: Jan 18 '19