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

Catkin_make generate services .h after building c++ code file?

asked 2013-03-02 11:14:05 -0600

phbou72 gravatar image

updated 2013-03-02 11:15:43 -0600

Hi, I have a problem with catkin_make that stop me from building my project. He seems to compile my c++ file before generating my message and service.

#### Running command: "make -j1 -l1" in "/home/philippe/design3/app/build"
Scanning dependencies of target Kinocto
[  7%] Building CXX object kinocto/CMakeFiles/Kinocto.dir/src/Kinocto.cpp.o
In file included from /home/philippe/design3/app/src/kinocto/src/Kinocto.cpp:1:0:
**/home/philippe/design3/app/src/kinocto/include/Kinocto.h:10:34: fatal error: kinocto/StartKinocto.h: No such file or directory**
compilation terminated.
make[2]: *** [kinocto/CMakeFiles/Kinocto.dir/src/Kinocto.cpp.o] Error 1
make[1]: *** [kinocto/CMakeFiles/Kinocto.dir/all] Error 2

In bold, wecan see that he can't find my service StartKinocto.h that doesnt exist because it havent been generated first... If I comment the code that use this service the service file is generated after Kinocto.cpp :

#### Running command: "make -j1 -l1" in "/home/philippe/design3/app/build"
Scanning dependencies of target Kinocto
[  7%] Building CXX object kinocto/CMakeFiles/Kinocto.dir/src/Kinocto.cpp.o
Linking CXX executable /home/philippe/design3/app/devel/lib/kinocto/Kinocto
[  7%] Built target Kinocto
Scanning dependencies of target kinocto_gencpp
[ 15%] Generating C++ code from kinocto/Num.msg
[ 23%] Generating C++ code from kinocto/AddTwoInts.srv
**[ 30%] Generating C++ code from kinocto/StartKinocto.srv**
[ 30%] Built target kinocto_gencpp
Scanning dependencies of target kinocto_genlisp
[ 38%] Generating Lisp code from kinocto/Num.msg
[ 46%] Generating Lisp code from kinocto/AddTwoInts.srv
**[ 53%] Generating Lisp code from kinocto/StartKinocto.srv**

Is that normal? What should I do?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-03-02 11:54:33 -0600

phbou72 gravatar image

OK, so I found out what was the problem... Even if your .srv is in your package you still need to add your package to his own dependencies... Kind of weird.

In my CMakeList.txt of the package kinocto I had:

add_executable(Kinocto src/Kinocto.cpp)

After the line above, I simply added this :

add_dependencies(Kinocto kinocto_gencpp)

No more error and the .srv files are generated.

I think it should be documented in the tutorials...

edit flag offensive delete link more



It is documented in this tutorial: (catkin). if you see another tutotiral that misses that, tell us of fix it.

KruseT gravatar image KruseT  ( 2013-03-02 12:41:55 -0600 )edit

@KruseT It should be documented in the CreatingMsgAndSrv Tutorial. This issue has proven to be a headache.

Sergio MP gravatar image Sergio MP  ( 2015-01-29 08:07:52 -0600 )edit

answered 2015-01-06 19:38:23 -0600

Pototo gravatar image

Also, if using catkin make sure this is part of your code

## Generate added messages and services with any dependencies listed here
## std_msgs is neccessary to generate message and service files

   LIBRARIES ptu46
   CATKIN_DEPENDS message_runtime
edit flag offensive delete link more

Question Tools


Asked: 2013-03-02 11:14:05 -0600

Seen: 1,130 times

Last updated: Jan 06 '15