# Set symbol visibility to hidden for RMW and RCL packages

**URL:** <https://discourse.openrobotics.org/t/set-symbol-visibility-to-hidden-for-rmw-and-rcl-packages/7981>\
**Category:** ROS General\
**Created:** [February 25, 2019, 9:32pm UTC](https://discourse.openrobotics.org/t/set-symbol-visibility-to-hidden-for-rmw-and-rcl-packages/7981 "2019-02-25T21:32:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhatsach](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@bhatsach](https://discourse.openrobotics.org/u/bhatsach)\
**Post date:** [February 25, 2019, 9:32pm UTC](https://discourse.openrobotics.org/t/set-symbol-visibility-to-hidden-for-rmw-and-rcl-packages/7981/1 "2019-02-25T21:32:01Z")

</div>

Hi all,

I am planning to work on a task to set symbol visibility to hidden for some of the RMW and RCL packages. The core rmw package has the header for symbol visibility definitions and has its cmake set visibility to hidden by default in the compile flags [1]. However other packages just have the visibility headers defined but not enabled in compile flags [2]. I am planning to make the changes to enable the same.

Please let me know your thoughts/any concerns about the same. It may happen that some downstream dependency is depending on a hidden symbol, however we do want to catch such cases and have them fixed if possible.

Regards,  
Sachin

[1] - [rmw/rmw/cmake/configure\_rmw\_library.cmake at master · ros2/rmw · GitHub](https://github.com/ros2/rmw/blob/master/rmw/cmake/configure_rmw_library.cmake#L44-L88)

[2] -

#### RMW packages

- rmw: [rmw/rmw/include/rmw/visibility\_control.h at master · ros2/rmw · GitHub](https://github.com/ros2/rmw/blob/master/rmw/include/rmw/visibility_control.h)
- rmw\_connext: [rmw\_connext/rmw\_connext\_cpp/include/rmw\_connext\_cpp/visibility\_control.h at master · ros2/rmw\_connext · GitHub](https://github.com/ros2/rmw_connext/blob/master/rmw_connext_cpp/include/rmw_connext_cpp/visibility_control.h)
- rmw\_fastrtps: [rmw\_fastrtps/rmw\_fastrtps\_cpp/include/rmw\_fastrtps\_cpp/visibility\_control.h at master · ros2/rmw\_fastrtps · GitHub](https://github.com/ros2/rmw_fastrtps/blob/master/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/visibility_control.h)

#### RCL packages:

- rcl: [rcl/rcl/include/rcl/visibility\_control.h at master · ros2/rcl · GitHub](https://github.com/ros2/rcl/blob/master/rcl/include/rcl/visibility_control.h)
- rcl\_action: [rcl/rcl\_action/include/rcl\_action/visibility\_control.h at master · ros2/rcl · GitHub](https://github.com/ros2/rcl/blob/master/rcl_action/include/rcl_action/visibility_control.h)
- rcl\_lifecycle: [rcl/rcl\_lifecycle/include/rcl\_lifecycle/visibility\_control.h at master · ros2/rcl · GitHub](https://github.com/ros2/rcl/blob/master/rcl_lifecycle/include/rcl_lifecycle/visibility_control.h)
- rcl\_yaml\_param\_parser: [rcl/rcl\_yaml\_param\_parser/include/rcl\_yaml\_param\_parser/visibility\_control.h at master · ros2/rcl · GitHub](https://github.com/ros2/rcl/blob/master/rcl_yaml_param_parser/include/rcl_yaml_param_parser/visibility_control.h)
- rclcpp: [rclcpp/rclcpp/include/rclcpp/visibility\_control.hpp at master · ros2/rclcpp · GitHub](https://github.com/ros2/rclcpp/blob/master/rclcpp/include/rclcpp/visibility_control.hpp)
- rclcpp\_action: [rclcpp/rclcpp\_action/include/rclcpp\_action/visibility\_control.hpp at master · ros2/rclcpp · GitHub](https://github.com/ros2/rclcpp/blob/master/rclcpp_action/include/rclcpp_action/visibility_control.hpp)
- rclcpp\_lifecycle: [rclcpp/rclcpp\_lifecycle/include/rclcpp\_lifecycle/visibility\_control.h at master · ros2/rclcpp · GitHub](https://github.com/ros2/rclcpp/blob/master/rclcpp_lifecycle/include/rclcpp_lifecycle/visibility_control.h)
- rcutils: [rcutils/include/rcutils/visibility\_control.h at master · ros2/rcutils · GitHub](https://github.com/ros2/rcutils/blob/master/include/rcutils/visibility_control.h)

---

<div class="post-metadata">

**Author:** ![wjwwood](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/wjwwood/32/13715_2.png) [@wjwwood](https://discourse.openrobotics.org/u/wjwwood)\
**Post date:** [February 25, 2019, 10:58pm UTC](https://discourse.openrobotics.org/t/set-symbol-visibility-to-hidden-for-rmw-and-rcl-packages/7981/2 "2019-02-25T22:58:11Z")

</div>

Updating more libraries to hind their symbols by default seems reasonable to me. Any cases where we’re using unintentionally referenced symbols should be addressed, as you said.

> [@bhatsach](#):
>
> However other packages just have the visibility headers defined but not enabled in compile flags [2].

The symbol visibility headers are used primarily for Windows, where symbols must be declared publicly, and implicitly referencing symbols will not work.

---

<div class="post-metadata">

**Author:** ![bhatsach](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@bhatsach](https://discourse.openrobotics.org/u/bhatsach)\
**Post date:** [February 26, 2019, 5:07pm UTC](https://discourse.openrobotics.org/t/set-symbol-visibility-to-hidden-for-rmw-and-rcl-packages/7981/3 "2019-02-26T17:07:38Z")

</div>

Thanks William, I have opened a couple of pull requests for RCL packages to get this started:

[https://github.com/ros2/rcl/pull/391](https://github.com/ros2/rcl/pull/391)  
[https://github.com/ros2/rclcpp/pull/638](https://github.com/ros2/rclcpp/pull/638)

---

<div class="post-metadata">

**Author:** ![Thomas\_Moulard](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/thomas_moulard/32/3770_2.png) [@Thomas\_Moulard](https://discourse.openrobotics.org/u/Thomas_Moulard)\
**Post date:** [February 26, 2019, 5:50pm UTC](https://discourse.openrobotics.org/t/set-symbol-visibility-to-hidden-for-rmw-and-rcl-packages/7981/4 "2019-02-26T17:50:41Z")

</div>

Thanks @wjwwood ! Our goal is to catch dllexport issues earlier by enabling this change.

---

<div class="post-metadata">

**Author:** ![alsora](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/alsora/32/2514_2.png) [@alsora](https://discourse.openrobotics.org/u/alsora)\
**Post date:** [July 29, 2019, 2:02pm UTC](https://discourse.openrobotics.org/t/set-symbol-visibility-to-hidden-for-rmw-and-rcl-packages/7981/5 "2019-07-29T14:02:06Z")

</div>

What’s the reason behind setting this in `rcl`?

```auto
rcl_set_symbol_visibility_hidden(${PROJECT_NAME} LANGUAGE "C")

```

This caused me some troubles since I was trying to use some rcl functions in my application.  
The linker immediately told me that some of them were hidden (and indeed I saw the RCL\_LOCAL macro).  
However, it was also not able to link against other functions marked as RCL\_PUBLIC.  
Then I noticed this line in the CMakeLists.txt, however the linker was not giving any hints for what concerns the RCL\_PUBLIC functions hidden by the aforementioned line.

I opened a question on ROSAnswers about how to set the logger programmatically since all these functions are hidden.  
[https://answers.ros.org/question/329532/ros2-how-to-programmatically-set-rosout-logging-handler/](https://answers.ros.org/question/329532/ros2-how-to-programmatically-set-rosout-logging-handler/)

---

<div class="post-metadata">

**Author:** ![wjwwood](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/wjwwood/32/13715_2.png) [@wjwwood](https://discourse.openrobotics.org/u/wjwwood)\
**Post date:** [July 29, 2019, 5:00pm UTC](https://discourse.openrobotics.org/t/set-symbol-visibility-to-hidden-for-rmw-and-rcl-packages/7981/6 "2019-07-29T17:00:43Z")

</div>

Functions marked as `RCL_PUBLIC` should be accessible for other libraries, if not open an issue on the package (I assume `rcl`) for which this isn’t the case.

Based on your question on ROS answers, I would guess one is just not public but maybe could be (again an issue asking to make it public would be best) and the other might be a bug (using `RCL_PUBLIC` rather than `RCL_LOGGING_PUBLIC` or something else).

---

<div class="post-metadata">

**Author:** ![alsora](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/alsora/32/2514_2.png) [@alsora](https://discourse.openrobotics.org/u/alsora)\
**Post date:** [August 1, 2019, 2:21pm UTC](https://discourse.openrobotics.org/t/set-symbol-visibility-to-hidden-for-rmw-and-rcl-packages/7981/7 "2019-08-01T14:21:28Z")

</div>

It was exactly as you said.

The `RCL_PUBLIC` function was not accessible due to a missing header [Fix rosout handler visibility by alsora · Pull Request #478 · ros2/rcl · GitHub](https://github.com/ros2/rcl/pull/478).  
For what concerns the other functions I opened a PR to make them public [rosout init and fini marked as RCL\_PUBLIC by alsora · Pull Request #479 · ros2/rcl · GitHub](https://github.com/ros2/rcl/pull/479)
