CMake Error (generate_messages) Example 6.8

after executing catkin_make i get


generate_messages at CmakeLists looks like that

Tried to remove build and devel, catkin_make --only-pkg-with-deps, copying directly from example 6.8, nothing helped

Hi @belkloilya ,

Welcome to this Community!

It seems that you have not exactly followed the instructions. I could infer this looking at your CMakeLists.txt file.

So what you have to do is:

  1. Include message_generation under find_package in your CMakeLists.txt file, like this:
find_package(catkin REQUIRED COMPONENTS
  rospy
  std_msgs
  message_generation # this package is important for custom messages
)
  1. Add the service file name to add_service_files() in CMakeLists.txt
add_service_files(
  FILES
  MyCustomServiceMessage.srv
)
  1. Your generate_messages() looks correct. You do not have to modify this.
generate_messages(
  DEPENDENCIES
  std_msgs  # Or other packages containing msgs
)
  1. Finally, you must add these three (3) lines into your package.xml file:
    (Make sure you have the same three lines for rospy and std_msgs)
  <build_depend>message_generation</build_depend>

  <build_export_depend>message_runtime</build_export_depend>

  <exec_depend>message_runtime</exec_depend>

Once you have all these, you should be able to re-build the package without any problems.

Let me know if this solves your problem.

Regards,
Girish

PS: If the custom message is not properly built, then you cannot run any script with rosrun that uses the custom message. It will produce error.

1 Like

Thank you so much! It finally works!