ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

build executable with msg

asked 2014-05-06 15:42:52 -0500

Younghyo gravatar image

I'm trying to build a source file using a message belonging to the same package.

In Package A - bb.cpp - cc.msg

The problem is that bb.cpp includes the header file of cc.msg - cc.h when I start to build as 'winros_make' it looks executables are built before the messages in there. i think messages should be built first and then executables be.

there are any way to build message first? so executable can access the header file of them.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-05-09 06:51:13 -0500

ahendrix gravatar image

You can add a dependency line to your CMakeLists.txt which declares that your executable depends on building messages:

add_dependencies(your_program ${your_package_EXPORTED_TARGETS})

For a more detailed explanation, see the building messages howto

edit flag offensive delete link more

Comments

i solved it by adding this. add_dependencies(bb A_gencpp) thank you.

Younghyo gravatar image Younghyo  ( 2014-05-12 16:25:07 -0500 )edit
-1

answered 2014-05-09 04:33:24 -0500

Bastbeat gravatar image

updated 2014-05-09 09:06:46 -0500

  • Try to delete your .cpp code from CMakelist
  • catkin_make or make (if you are in Catkin or in Rosbuild) to create correctly your "cc.h"
  • include again your .cpp in CMakelist
  • catkin_make or make again
edit flag offensive delete link more

Comments

This is not a good idea, because you'll have to repeat it any time you want to change the message definitions in your package. It's much better to explicitly declare your message dependencies; your program will always build in order, and it will be automatically rebuilt when your msg files change.

ahendrix gravatar image ahendrix  ( 2014-05-09 09:21:07 -0500 )edit

Ok, thank you very much.

Bastbeat gravatar image Bastbeat  ( 2014-05-09 20:24:08 -0500 )edit

Question Tools

Stats

Asked: 2014-05-06 15:42:52 -0500

Seen: 384 times

Last updated: May 09 '14