ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
This is a common issue people have with catkin. See here, here, and here.
Your assessment is correct that the executable is being built before the message headers. In catkin, you must explicitly tell cmake that your code depends on those message targets to ensure the build order gets resolved correctly. The catkin how-to suggests that the best way to resolve this is to add the following line to your CMakeLists.txt
:
add_dependencies(your_program ${catkin_EXPORTED_TARGETS})
This will force your code to build after all its listed dependencies, which is safe, but maybe more conservative than required. I haven't tried it, but the solution listed here suggests that you can, instead, use the following line to explicitly state that you're depending on the message-headers only:
add_dependencies(your_program msg_pkg_generate_messages_cpp)
That last method is used in the wiki tutorial on custom messages.