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

i include #include " foo_msgs/Foo.h " in my pubsub/src/listener.cpp but when i build using "catkin_make " it shows an error foo_msgs/Foo.h : No such file or directory

asked 2015-05-19 10:05:34 -0500

dash95 gravatar image

updated 2015-05-20 04:27:40 -0500

i i am still getting error foo_msgs/Foo.h : No such file or directory

i have a catkin_ws/src this includes packages
foo_msgs pubsub

foo_msgs contains 1) msg 2)CMakeList.txt 3)package.xml

pubsub contains 1) src 2)CMakeList.txt 3)package.xml

foo_msgs/msg/Foo.msg

int32 bar

its CMakeList.txt

////////////////////

cmake_minimum_required(VERSION 2.8.3)
project(foo_msgs)

find_package(catkin REQUIRED COMPONENTS std_msgs message_generation)


add_message_files(
        DIRECTORY msg
        FILES Foo.msg)


generate_messages(DEPENDENCIES std_msgs)

catkin_package(CATKIN_DEPENDS std_msgs message_runtime)

/////////////////////

<?xml version="1.0"?>
< package  >
  <   name>foo_msgs</name >
  < version>0.1.0</version >
  < description>The foo_msgs package< /description >

  < maintainer email="bar@baz.com "  >william< /  maintainer >

  < license>TODO</license>

  < buildtool_depend>catkin</buildtool_depend >

  < build_depend>message_generation</build_depend >
  < run_depend>message_runtime</run_depend >

  <  build_depend>std_msgs</build_depend >
  <  run_depend>std_msgs</run_depend >

< /package >

////////////////////////

pubsub/CMakeList.txt //////////////////////

cmake_minimum_required(VERSION 2.8.3)

project(pubsub)

find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs )

find_package(foo_msgs)

catkin_package()

include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(listener src/listener.cpp)

target_link_libraries(listener ${catkin_LIBRARIES})

add_dependencies(listener foo_msgs_generate_messages_cpp ${catkin_EXPORTED_TARGETS})

//////////////////////////////////////////////////

<?xml version="1.0"?>

< package >

  <  name >pubsub< /name >

  < version >0.0.0< /version >

  < description  >The pubsub package</description >

< maintainer email="xyx@todo.todo >danish< /maintainer >
n
 <  license >TODO<  /license>



 < buildtool_depend  >catkin< /buildtool_depend >

  < build_depend >roscpp< /build_depend >

  < build_depend >rospy< /build_depend >

  < build_depend >std_msgs< /build_depend >

  < run_depend >roscpp< /run_depend >

< build_depend>foo_msgs</build_depend >

  < run_depend>rospy</run_depend >


  < run_depend>std_msgs</run_depend >

  < run_depend>foo_msgs</run_depend >


< export >

  < /export >
< /package >

/////////////////////////////////////// .......................................

i include #include " foo_msgs/Foo.h " in my pubsub/src/listener.cpp but when i build using "catkin_make " it shows an error foo_msgs/Foo.h : No such file or directory Please Help Thanx in advance

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-05-19 11:31:32 -0500

ahendrix gravatar image

You don't do anything in the CMakeLists.txt of your pubsub package which would add the include directory for your foo_msgs package to your include directory path.

Normally, when you depend on one package from another, you should use catkin to find it, the same you do for other ROS packages:

find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs foo_msgs)

This automatically adds the include paths for roscpp, rospy, std_msgs and foo_msgs to the ${catkin_INCLUDE_DIRS} variable.

You then add these include directories to your include search path using:

include_directories(${catkin_INCLUDE_DIRS})

Or

include_directories(include ${catkin_INCLUDE_DIRS}) # if your package contains an include directory that you are using
edit flag offensive delete link more

Comments

find_package(catkin REQUIRED COMPONENTS foo_msgs)

include_directories(include ${catkin_INCLUDE_DIRS})

include_directories(${catkin_INCLUDE_DIRS})

I have included these to statements in CMakeList ofpubsub..................still getting same error ....... please help . Thanks in advance

dash95 gravatar image dash95  ( 2015-05-20 04:22:40 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-05-19 10:05:34 -0500

Seen: 149 times

Last updated: May 20 '15