ROS2 Missing ament_export_target in diagnostic_aggregation CMake
AzaelCicero opened this issue · comments
I am writing my own plugin for the diagnostic and I needed to call StatusItem::toStatusMsg
https://github.com/ros/diagnostics/blob/galactic/diagnostic_aggregator/include/diagnostic_aggregator/status_item.hpp#L222-L224
I was getting a linking error:
/usr/bin/ld: libas_monitor_analyzers_lib.so: undefined reference to `diagnostic_aggregator::StatusItem::toStatusMsg(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, bool) const'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/as_monitor_analyzers_test.dir/build.make:210: as_monitor_analyzers_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:125: CMakeFiles/as_monitor_analyzers_test.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
The issue is that CMake does not export the diagnostic_aggregator library: https://github.com/ros/diagnostics/blob/galactic/diagnostic_aggregator/CMakeLists.txt#L158-L164
It should look like this:
ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET)
ament_export_libraries(${PROJECT_NAME})
Is it by design?
I agree. I think we can close this