Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined reference to rcl_logging functions #476

Closed
alsora opened this issue Jul 29, 2019 · 2 comments
Closed

Undefined reference to rcl_logging functions #476

alsora opened this issue Jul 29, 2019 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@alsora
Copy link
Contributor

alsora commented Jul 29, 2019

Bug report

Required Info:

  • Operating System:
    • Ubuntu 18.04
  • Installation type:
    • source
  • Version or commit hash:
    • master
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

#include "rclcpp/rclcpp.hpp"
#include "rcl/logging_rosout.h"
#include <rcl/logging.h>
using namespace std::chrono_literals;

class LoggerNode : public rclcpp::Node
{
public:
  LoggerNode()
  : Node("logger_node")
  {
    //auto allocator = rcl_get_default_allocator();
    //rcl_ret_t status = rcl_logging_rosout_init(&allocator);
    rcutils_logging_set_output_handler(rcl_logging_rosout_output_handler);
   
    auto timer_callback =
      [this]() -> void {
        RCLCPP_INFO(this->get_logger(), "Hello World");
      };
    timer_ = this->create_wall_timer(500ms, timer_callback);
  }

private:
  rclcpp::TimerBase::SharedPtr timer_;
};

int main(int argc, char * argv[])
{
  rclcpp::init(argc, argv);
  rclcpp::spin(std::make_shared<LoggerNode>());
  rclcpp::shutdown();
  return 0;
}

Expected behavior

I create a node with a custom logging output handler (in this case it should only log to rosout topic).

Actual behavior

The above code doesn't build as I get a linker error:

undefined reference to `rcl_logging_rosout_output_handler'

This function is marked as RCL_PUBLIC, so it should be accessible.

Note that if I comment the following line in rcl/CMakeLists.txt the compilation succeeds.

rcl_set_symbol_visibility_hidden(${PROJECT_NAME} LANGUAGE "C")

Additional notes

On the other hand, the function rcl_logging_rosout_init is marked as RCL_LOCAL, thus it's hidden and I can't use it in my code.
Assuming that the rcl_logging_rosout_output_handler has to be accessible somehow, there should also be a way for checking if it has already been initialized and to initialize it.

This issue is linked to

https://answers.ros.org/question/329532/ros2-how-to-programmatically-set-rosout-logging-handler/
https://discourse.ros.org/t/set-symbol-visibility-to-hidden-for-rmw-and-rcl-packages/7981/5?u=alsora

@nuclearsandwich nuclearsandwich added the bug Something isn't working label Aug 15, 2019
@wjwwood
Copy link
Member

wjwwood commented Aug 22, 2019

@alsora can this be closed now that the pr's have been merged? Or is there more to do?

@alsora
Copy link
Contributor Author

alsora commented Aug 22, 2019

Yes, the PRs fixes this issue.

@alsora alsora closed this as completed Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants