I am using Ubuntu 16.04 LTS with ROS Kinetic distro.

I have a custom package called gps_msgs in my catkin_ws directory. I have other two packages that utilize the message by including it into source.

Now, one of the packages doesn't build without having "gps_msgs" inside the find_package() macro in CMakeLists.txt whereas the other one does.

The packages are nearly identical apart from the fact that one of them utilizes a 3rd party library. Here's the CMakeLists (package.xml files are almost identical, none of them include gps_msgs, I would like to know why that works too..):

Package #1:

cmake_minimum_required(VERSION 2.8.3)


find_package(catkin REQUIRED COMPONENTS

# include

add_executable(can_control_node src/control_node.cpp)
target_link_libraries(can_control_node ${catkin_LIBRARIES})

Package #2:

cmake_minimum_required(VERSION 2.8.3)


find_package(catkin REQUIRED COMPONENTS

  #CATKIN_DEPENDS std_msgs roscpp
  #INCLUDE_DIRS include


include_directories(include/${PROJECT_NAME} ${catkin_INCLUDE_DIRS})


target_link_libraries(gps_node ${catkin_LIBRARIES})

Again, both packages have #include <gps_msgs/Navigation.h> in their source files. The gps_msgs/Navigation isn't mentioned AT ALL in either of the package.xml files. Package #1 builds, package #2 complains that gps_msgs/Navigation doesn't exist. All 3 packages are in separate directories in my catkin_ws, what's going on?

  • 1
    i would suggest to try to ask that on ROS answers website as the community there is 100% dedicated to ROS – N. Staub Dec 3 at 12:50
  • @N.Staub I have, I have a basic solution why but no real answer. – Hypomania Dec 4 at 9:51

I have managed to fix the issue.

I am still uncertain as to why it happens, catkin can be very unpredictable and what builds on one system doesn't builds on another one (experienced that yesterday).

This is an actual convention and has to be followed to achieve proper building sequence whenever you're trying to include a c:

  1. Add your message in package.xml in the <depend>your_msg</depend> tag.
  2. Add your message in CMakeLists.txt in the find_packages(catkin REQUIRED COMPONENTS roscpp your_msg) macro.
  3. Add include_directories(include ${catkin_INCLUDE_DIRS}) macro in CMakeLists.txt to get the message headers.
  4. Use add_dependencies(your_node ${catkin_EXPORTED_TARGETS}) macro in CMakeLists.txt to ensure that your messages are built first before building your target (most important step).

Hope this helps someone who is getting (message no found error during catkin_make).

Reference: catkin docs

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.