I don’t know how to explain this problems, but here it is:
- I have a package named
tosshin_interfaces
which contains ROS 2 interfaces. - There is
tosshin_cpp
package that usetosshin_interfaces
and containsNavigationProvider
class. - The
NavigationProvider
class provide publishers and subscribers (hence it usestosshin_interfaces
) - The
tosshin_cpp
is compiled into a library. - I have another package,
tosshin_gazebo_plugins
, it’s created a gazebo_plugins and had a dependency onNavigationProvider
.
Then i compiled it, all is working. But when i try to include it in the Gazebo model, and run it. It logs the following linker error:
[gazebo-1] [INFO] [1619293761.052097435] [camera]: Compressed image publisher initialized on /camera/compressed_image!
[gazebo-1] [INFO] [1619293761.066926145] [navigation]: Node initialized on navigation!
[gazebo-1] gzserver: symbol lookup error: /home/threeal/Documents/dienen_ws/install/tosshin_gazebo_plugins/share/tosshin_gazebo_plugins/plugins/libtosshin_navigation_plugin.so: undefined symbol: _ZN22rosidl_typesupport_cpp31get_message_type_support_handleIN18tosshin_interfaces3msg9Odometry_ISaIvEEEEEPK29rosidl_message_type_support_tv
[ERROR] [gazebo-1]: process has died [pid 57834, exit code 255, cmd 'gazebo --verbose /home/threeal/Documents/dienen_ws/install/dienen_sim/share/dienen_sim/worlds/default.sdf'].
My clue is, when i comment the code in the NavigationProvider
which contains publishers and subscribers initialization, it’s working fine (no errors on both compile and execution). So i think it related to the rosidl_typesupport_cpp
package as in that error logs.
Then i try to declare the publishers and subscribers initialization in the gazebo plugin instead of the NavigationProvider
, amazingly, it’s working fine. But still not working on the NavigationProvider
.
Then i try to use shared library, still not working.
Then i try many ways to fix this problem, until then i got and idea to replace the library with header only. And then it’s working fine.
My question is why ROS 2 cannot execute dependency’s library that contains publisher and subscription declaration? why it’s fine when the declaration is in the same package and not different package (i use header only, so it could be treated as compilation in the same package)?
For note, i use the same compilation process (CMakeLists) as in many projects that using ROS 2.