ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
"Undefined reference" usually means that you're compiling against the headers for a library, but aren't linking to that library during your final link phase.
In CMake, you usually link an executable to a library using the target_link_libraries()
command.
Depending on if or how you're finding the libserial package from CMake, you'll want to do different things.
If you're using find_package to find libserial, you'll want something like:
target_link_libraries(my_node ${libserial_LIBRARIES})
But if you're just assuming that the system has libserial installed, and you normally pass -lserial
to link to it, you probably want to do:
target_link_libraries(my_node serial)