Ask Your Question

Catkin: Use ROS message from another package

asked 2015-03-30 11:12:15 -0500

potAito gravatar image

Hi guys

I'm trying to use a ROS message defined in another package, lets say message_package in my own package which I will call myPackage. The problem I have is that catkin first tries to build myPackage before message_package. Hence I get a compilation error:

fatal error: message_package/msg.h: No such file or directory #include "message_package/msg.h"

I don't understand why catkin does that. In the package.xml of myPackage I added

<build_depend> message_package </build_depend>

and in the CMakeLists.txt I added

find_package(catkin REQUIRED COMPONENTS
message_package )

What else can I do to tell catkin to compile message_package BEFORE myPackage, so that the necessary headers are there?

edit retag flag offensive close merge delete


Why nobody upvotes question? :( (I gave u upvote, thanks)

martinerk0 gravatar image martinerk0  ( 2021-07-15 16:54:55 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-03-30 11:40:38 -0500

ahendrix gravatar image

You need to add a build-time dependency between your package and the packages you depend on. Assuming the node you're trying to compile is called your_executable, try:

add_dependencies(your_executable ${catkin_EXPORTED_TARGETS})
edit flag offensive delete link more


Huh it's working, thanks. I thought that's taken care of with build_depend. What exactly is ${catkin_EXPORTED_TARGETS}?

potAito gravatar image potAito  ( 2015-03-30 11:48:36 -0500 )edit

It is a CMake variable containing all the targets exported by packages you depend on. See: for details.

joq gravatar image joq  ( 2015-03-31 10:46:56 -0500 )edit

Aha! Thank you very much!

potAito gravatar image potAito  ( 2015-03-31 11:36:29 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-03-30 11:12:15 -0500

Seen: 12,640 times

Last updated: Mar 30 '15