Link error: undefined constructor for ROSType
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,
RosIntrospection::ROSType(datatype),
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?