ROS2 interfacing with gazebo causes gzserver: symbol lookup error

asked 2019-08-05 12:34:14 -0500

fremad gravatar image

updated 2022-06-11 10:40:45 -0500

lucasw gravatar image

Trying to make a plugin for gazebo connected with ROS2. I am using the rclcpp API but creating subscriptions is cauting errors. The load function is shown below:

void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf)

    int argc = 0;
    char **argv = NULL;
    rclcpp::init(argc, argv);
    // rclcpp::spin(std::make_shared<MinimalSubscriber>());
    // rclcpp::shutdown();
    auto node = rclcpp::Node::make_shared("ObiWan");
        [node](std_msgs::msg::String::UniquePtr msg) {
            RCLCPP_INFO(node->get_logger(), "I heard: '%s'", msg->data.c_str());

    //Logs to node log, pretty cool really! :D
                "PLease help me kenobi '%s'", node->get_name());

The problem seems to arrive when calling the create_subscription(...).

I get the error:

gzserver: symbol lookup error: /home/lars/gaz-tryout3/build/ undefined symbol: _ZN22rosidl_typesupport_cpp31get_message_type_support_handleIN8std_msgs3msg7String_ISaIvEEEEEPK29rosidl_message_type_support_tv

any ideas for a fix, or some info on why this is happening?

Running gazebo9 ROS2 dashing and ros-dashing-gazebo-ros-pkgs

cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
find_package(gazebo REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)


add_library(hello_world SHARED
target_link_libraries(hello_world ${GAZEBO_LIBRARIES} ${rclcpp_LIBRARIES})

You were right, forgot to link the std_msgs. I linked them properly and now it works :)

target_link_libraries(hello_world ${GAZEBO_LIBRARIES} ${rclcpp_LIBRARIES} ${std_msgs_LIBRARIES})

If anybody needs the same

edit retag flag offensive close merge delete


Could you also give your CMakeLists.txt? It looks to me as if you don't link correctly to your std_msgs packages and/or haven't sourced your ROS2 installation correctly before building.

Karsten gravatar image Karsten  ( 2019-08-05 14:15:33 -0500 )edit

Please edit your original question text, comments are not suited for posting code or build scripts.

Use the edit button/link for that.

gvdhoorn gravatar image gvdhoorn  ( 2019-08-05 14:25:58 -0500 )edit

Please post the last part of your question text (that you added in your last edit) as an answer and accept your own answer.

That will show clearly that your question was answered.

gvdhoorn gravatar image gvdhoorn  ( 2019-08-05 14:39:16 -0500 )edit