Ask Your Question

ros/ros.h header file not found

asked 2019-10-19 20:29:04 -0600

AldoChavez0212 gravatar image

updated 2019-10-20 01:14:19 -0600

gvdhoorn gravatar image

Hello, I'm pretty new to ROS and I'm implementing a Service node in C++, the problem is, when I try to include the "ros/ros.h" header file, it is not found, and the header file of my service file isn't found either, although it is correctly contained in catkin_ws/devel/include/my_package, I've found that this problem is often caused by an error of configuration in the CMakeLists.txt, but I tried the solutions that were posted in the thread I consulted and it didn't help. My ROS version is Kinetic Kame and I'm using Ubuntu 16.04.

Here's my CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)




   INCLUDE_DIRS include
   LIBRARIES beginner_tutorials
   CATKIN_DEPENDS roscpp rospy std_msgs message_runtime
   DEPENDS system_lib


add_executable(talker src/talker.cpp)
target_link_libraries(talker ${catkin_LIBRARIES})
add_dependencies(talker beginner_tutorials_generate_messages_cpp)

add_executable(listener src/listener.cpp)
target_link_libraries(listener ${catkin_LIBRARIES})
add_dependencies(listener beginner_tutorials_generate_messages_cpp)

add_executable(SumarServer src/add_two_ints_server.cpp)
target_link_libraries(SumarServer ${catkin_LIBRARIES})
add_dependencies(SumarServer beginner_tutorials_gencpp)

add_executable(SumarClient src/add_two_ints_client.cpp)
target_link_libraries(SumarClient ${catkin_LIBRARIES})
add_dependencies(SumarClient beginner_tutorials_gencpp)

add_executable(CCServer src/CCServer.cpp)
target_link_libraries(CCServer ${catkin_LIBRARIES})
add_dependencies(CCServer beginner_tutorials_gencpp)

And my package.xml just in case:

<?xml version="1.0"?>
<package format="2">
  <description>This package was created to follow the tutorial</description>

  <maintainer email="aldo@todo.todo">aldo</maintainer>




I would really appreciate the help, guys

edit retag flag offensive close merge delete


This could be a result of an unorthodox directory structure. Do you have a "srv" folder and an "include" folder that contains the mentioned files in the src/my_package directory (e.g. my_package/srv and my_package/include)?

PSA gravatar image PSA  ( 2019-10-19 23:52:25 -0600 )edit

Oh, my bad, I forgot to mention that, yes, I'm using the suggested folder structure, but the problem was just my IDE's configuration. Thanks a lot for your help!

AldoChavez0212 gravatar image AldoChavez0212  ( 2019-10-20 21:20:58 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-10-20 09:38:36 -0600

fergs gravatar image

I don't see your "find_package(catkin ...)" near the start of the posted CMakeLists.txt - I'm actually surprised you aren't getting lots of CMake config errors. Check out the details of find_package on the ROS wiki

edit flag offensive delete link more


Oh, yes, actually I erased that line trying to fix the issue desperately lol, but it was meant to be on the file, thank you very much. I found the actual error, it was simply the IDE I'm using that just had trouble recognizing the location of the header files, but when running the node through the Ubuntu console it works just fine. Again, thanks a lot for your help!

AldoChavez0212 gravatar image AldoChavez0212  ( 2019-10-20 21:19:01 -0600 )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: 2019-10-19 20:29:04 -0600

Seen: 578 times

Last updated: Oct 20 '19