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

macOS | Foxy | issue with linking std_msgs

asked 2020-11-04 07:20:12 -0500

Domingo gravatar image

Hi,

I'm using ROS2 Foxy on macOS Catalina.

I'm able to run turtlesim node as well as simplest node written by myself. However when I try to create publisher with type std_msgs::msg::String I got error:

Undefined symbols for architecture x86_64: "rosidl_message_type_support_t const* rosidl_typesupport_cpp::get_message_type_support_handle<std_msgs::msg::string_<std::__1::allocator<void> > >()", referenced from: rclcpp::Publisher<std_msgs::msg::string_<std::__1::allocator<void> >, std::__1::allocator<void> >::Publisher(rclcpp::node_interfaces::NodeBaseInterface, std::__1::basic_string<char, std::__1::char_traits<char="">, std::__1::allocator<char> > const&, rclcpp::QoS const&, rclcpp::PublisherOptionsWithAllocator<std::__1::allocator<void> > const&) in number_publisher.cpp.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [number_publisher_node] Error 1 make[1]: [CMakeFiles/number_publisher_node.dir/all] Error 2 make: ** [all] Error 2

Code looks as follows:

#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"

class NumberPublisher : public rclcpp::Node
{
private:
    void timer_callback()
    {
        auto msg = std_msgs::msg::String();
        msg.data = "2";
        m_publisher->publish(msg);
    }
    rclcpp::Publisher<std_msgs::msg::String>::SharedPtr m_publisher;
    rclcpp::TimerBase::SharedPtr m_timer;

public:
    NumberPublisher() : Node("number_publisher")
    {
        m_publisher = this->create_publisher<std_msgs::msg::String>("topic", 10);
        m_timer = this->create_wall_timer(std::chrono::seconds(1), std::bind(&NumberPublisher::timer_callback, this));

        RCLCPP_INFO(this->get_logger(), "NumberPublisher created");
    }
};
int main(int argc, char **argv)
{
    rclcpp::init(argc, argv);
    auto node = std::make_shared<NumberPublisher>();
    rclcpp::spin(node);
    rclcpp::shutdown();
    return 0;
}

In CMakeList.txt I added:

find_package(std_msgs REQUIRED)

In package.xml I added:

<depend>std_msgs</depend>
edit retag flag offensive close merge delete

Comments

How did you install Foxy? FWIW, only macOS Mojave is officially supported for Foxy.

jacobperron gravatar image jacobperron  ( 2020-11-06 12:24:18 -0500 )edit

Also, in your CMakeLists.txt you should make sure you are linking your executable against std_msgs. E.g. with ament: ament_target_dependencies(number_publisher_node "std_msgs")

jacobperron gravatar image jacobperron  ( 2020-11-06 12:26:36 -0500 )edit

@jacobperron To install Foxy on macOS I followed the instruction on ros.org After many issues I decided to install Ubuntu on my mac and am starting with ROS on it. Unfortunately I already removed that ROS project and can't check in CMakeLists.txt if I linked executables against std_msg, but I think I did. Thanks for reply!

Domingo gravatar image Domingo  ( 2020-11-07 03:52:26 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-11-09 11:58:10 -0500

jacobperron gravatar image

If you followed the binary install instructions for macOS on Catalina, I would not expect the installation to be compatible since the target platform is macOS Mojave. If you would like to try running ROS 2 on Catalina, you could try building from source, but there are no guarantees that it will work since there is no official support for Catalina at this time.

edit flag offensive delete link more

Comments

I don't want to spend more time on the issues with ROS and macOS, so I will stay with Ubuntu. It does not work perfect on macbook (no sound...) but so far no issues with ROS on it. Do you know if there any plans to support newer versions of macOS?

Domingo gravatar image Domingo  ( 2020-11-12 10:36:17 -0500 )edit

It's possible that a new ROS distribution will support the latest version of macOS, though we sometimes lag behind depending how smoothly the migration goes. So maybe Catalina will be supported for Galactic or H-turtle; no promises.

jacobperron gravatar image jacobperron  ( 2020-11-13 08:03:18 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2020-11-04 07:20:12 -0500

Seen: 158 times

Last updated: Nov 09 '20