Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The problem here was that matrix2_msgs was not being linked into matrix2_ros. Since the compiler generates an actual instance of the template method, it is not found in rmw_fastrtps_cpp (which defines the template), but instead in matrix2_msgs__rosidl_typesupport_cpp (which instantiates the template).

I solved it by explicitely telling cmake where to look for that library, since ament didn't pick it up as the necessary environment variables are not set after generation.

add_library(matrix2_msgs_imported SHARED IMPORTED)
set_target_properties(matrix2_msgs_imported PROPERTIES
    IMPORTED_LOCATION "${ros_msg_dir}/libmatrix2_msgs__rosidl_typesupport_cpp.so"
)
target_link_libraries(${PROJECT_NAME} matrix2_msgs_imported)

Lesson learned: When looking at linking errors involving templates, think hard about where that symbol is actually generated.