ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A
Ask Your Question

Undefined reference to RosIntrospection functions

asked 2018-08-20 07:48:25 -0500

Felix394 gravatar image

updated 2018-08-21 02:10:29 -0500

gvdhoorn gravatar image

Hey guys,

I try to convert the Raw Buffer of a ShapeShifter to its original DataType Structure. But I have Problems understanding the new API. In the wiki the author used functions, which are not available anymore, so I tried to do it with the latest headers available.

As I understand the new API, I have to register the MessageDefinition first and afterwards I can deserialize the Buffer IntoFlatContainer.

Copy of the ros_type_introspection.hpp: In the file is a short description to each function

  void registerMessageDefinition(const std::string& message_identifier,
                                 const ROSType &main_type,
                                 const std::string& definition);

  bool deserializeIntoFlatContainer(const std::string& msg_identifier,
                                    absl::Span<uint8_t> buffer,
                                    FlatMessage* flat_container_output,
                                    const uint32_t max_array_size ) const;

Here is my code:

using namespace RosIntrospection;

static std::vector<uint8_t> buffer;
static FlatMessage flat_container;
Parser parser;    
const std::string& datatype   = msg->getDataType();
const std::string& definition = msg->getMessageDefinition();

ROS_INFO("datatype: %s", datatype.c_str() );

buffer.resize( msg->size() );
ros::serialization::OStream stream(, buffer.size());

parser.registerMessageDefinition(datatype, ROSType("geometry_msgs/Twist"), definition);

The registration of the MessageDefinition fails. And functions like described in the wiki (e.g buildROSTypeMapFromDefinition) are not available anymore.

My current error message:

RosSender.cpp:(.text+0x3cc): undefined reference to `RosIntrospection::ROSType::ROSType(absl::string_view)'
RosSender.cpp:(.text+0x3ed): undefined reference to `RosIntrospection::Parser::registerMessageDefinition(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, RosIntrospection::ROSType const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)

Can anyone tell me how to use the new API correctly to get the original message?

Thank you!!

edit (Add CMakeList.txt):

cmake_minimum_required(VERSION 2.8.3)

set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_CXX_FLAGS "-std=c++14")


find_package(catkin REQUIRED COMPONENTS

  LIBRARIES RosAdapter
  CATKIN_DEPENDS roscpp rospy std_msgs
  DEPENDS system_lib


add_executable(RosSender src/RosSender.cpp)

target_link_libraries(RosSender ${catkin_LIBRARIES} ${THIRDPARTY_DIR}/oa/
target_link_libraries(RosSender /opt/ros/kinetic/lib/
edit retag flag offensive close merge delete


The last error is a linker error, not something else.

So apparently the compiler is happy, but the linker can't find the specific symbol it needs to link your executable.

Are you enabling / using C++11 in your pkg and linking the ros_type_introspection libraries correctly?

gvdhoorn gravatar imagegvdhoorn ( 2018-08-20 08:56:07 -0500 )edit

set(CMAKE_CXX_FLAGS "-std=c++11") set(CMAKE_CXX_FLAGS "-std=c++14") these are my link libraries: target_link_libraries(RosSender ${catkin_LIBRARIES}) target_link_libraries(RosSender /opt/ros/kinetic/lib/ I don't have other *.so files to link

Felix394 gravatar imageFelix394 ( 2018-08-20 09:31:01 -0500 )edit

Please add this to your original question text. Comments are too limited.

re: set(CMAKE_CXX_FLAGS ..): don't do this. If you must use set(..), use set(VAR "new entry $VAR") so as to not override whatever was already there.

gvdhoorn gravatar imagegvdhoorn ( 2018-08-20 11:55:54 -0500 )edit

Can you please add your complete CMakeLists.txt to your question?

I don't understand why you're listing the absolute path to the topic_tools library like that.

gvdhoorn gravatar imagegvdhoorn ( 2018-08-20 11:56:59 -0500 )edit

I had to add the path, because otherwise I got Linking Problems

Felix394 gravatar imageFelix394 ( 2018-08-21 01:31:25 -0500 )edit

Could I refer you to wiki/catkin/CMakeLists.txt? topic_tools is a Catkin pkg, so it should appear in your find_package(catkin REQUIRED COMPONENTS ..) call.

There are some other unusual things in your CMakeLists.txt file as well.

gvdhoorn gravatar imagegvdhoorn ( 2018-08-21 01:33:58 -0500 )edit

Fi: you have DEPENDS system_lib in there. But you never actually build a library called system_lib. If you don't intend to, remove the DEPENDS system_lib line.

gvdhoorn gravatar imagegvdhoorn ( 2018-08-21 01:34:58 -0500 )edit

Could you also please use the Preformatted Text button when copy-pasting code/build scripts/console text? It's the one with 101010 on it. That would make things much easier to read.


gvdhoorn gravatar imagegvdhoorn ( 2018-08-21 01:36:46 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-08-21 01:38:57 -0500

gvdhoorn gravatar image

updated 2018-08-21 02:04:40 -0500

I'm not sure, but I don't see ros_type_introspection (ie: the Catkin package) appear anywhere in your CMakeLists.txt.

As you're using the package, I would expect it to appear at least in:

find_package(catkin REQUIRED COMPONENTS .. ros_type_introspection ..)


catkin_package(.. CATKIN_DEPENDS .. ros_type_introspection ..)

Linking against catkin_LIBRARIES should then allow the linker to resolve all used symbols.

Edit: the same goes for topic_tools. It's a Catkin package as well, so I would expect it to appear in the same places as ros_type_introspection.

Edit2: also don't forget to add the correct build and exec dependencies to your package.xml. See the catkin documentation for how to do that.

Edit3: based on what you show us, I would expect to see a CMakeLists.txt like the following:

cmake_minimum_required(VERSION 2.8.12)


# this overrides the C++11 enabled before this line

# 'pretend' OaLib is a nice CMake findable pkg
# we don't bother with find_library et al. and shortcut things a bit
add_library(OaLib STATIC IMPORTED)

# rospy is not a build dependency, so can probably be removed here
find_package(catkin REQUIRED COMPONENTS

# check order of include directories here

  # you don't export any include directories, so this should be removed
  # this library is not being built, so this line should be removed
  LIBRARIES RosAdapter
  # rospy should be removed here as well: it cannot be a build dependency
  CATKIN_DEPENDS roscpp rospy std_msgs ros_type_introspection topic_tools

add_executable(RosSender src/RosSender.cpp)
target_link_libraries(RosSender ${catkin_LIBRARIES} OaLib)

I've added some comments above lines I can't be sure about, so check those yourself.

Linking static libraries like you did is not recommended, so I replaced it with an imported target.

And please note: this is all CMake, not Catkin or special to ROS.

edit flag offensive delete link more


I have never build a package ros_type_introspection, because I only have the header files from the git repo. Add it to the CMakeLists as package will throw an exception.

Felix394 gravatar imageFelix394 ( 2018-08-21 01:45:22 -0500 )edit

ros_type_introspection is a ROS package. Just the header files are not enough to successfully use it.

If you are on Ubuntu, just do a sudo apt install ros-$distro-ros-type-introspection.

I cannot help you further without more information on your build environment (OS, versions, etc).

gvdhoorn gravatar imagegvdhoorn ( 2018-08-21 01:52:59 -0500 )edit

Ok shame on me, I was completely stumped staring at my monitor like wtf

Felix394 gravatar imageFelix394 ( 2018-08-21 01:59:07 -0500 )edit

Thank you so much !!

Felix394 gravatar imageFelix394 ( 2018-08-21 02:01:26 -0500 )edit

Your question had me thoroughly confused, as I assumed you knew how to set this all up.

From #q299711 I had assumed (perhaps wrongly) that you were a bit more experienced with all this -- writing middleware bridges is not typically a task for first-timers.

gvdhoorn gravatar imagegvdhoorn ( 2018-08-21 02:03:57 -0500 )edit

Your Answer

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

Add Answer

Question Tools


Asked: 2018-08-20 07:48:25 -0500

Seen: 136 times

Last updated: Aug 21 '18