ROS noetic, fatal error: ros/ros.h: No such file or directory

asked 2021-05-18 04:05:17 -0500

lucat gravatar image

Hi everyone, I'm trying to start a c++ script (simply the listener from the ROS tutorial, just with the name subpub.cpp) but I get the error "fatal error: ros/ros.h: No such file or directory".

I tried looking at the old questions about this, but they don't seem to work for me.

I am using noetic on ubunto, and the catkin_make does not give any errors.

this is my package.xml file:

<?xml version="1.0"?>
<package format="2">
  <description>The infoexc package</description>
  <maintainer email="cnr@todo.todo">cnr</maintainer>
    <!-- Other tools can request additional information be placed here -->

and this is my CMakeLists.txt file:

cmake_minimum_required(VERSION 3.0.2)

find_package(catkin REQUIRED COMPONENTS
add_executable(subpub scripts/C++/subpub.cpp)
target_link_libraries(subpub ${catkin_LIBRARIES})

Scripts in c++ are in /catkin_ws/src/infoexc/scripts/C++, everything worked fine in python.

Thanks in advance!

edit retag flag offensive close merge delete


I think the error is related to 'Visual Studio code', I should add the libraries to the path I think, but I don't know how.

lucat gravatar image lucat  ( 2021-05-18 04:48:02 -0500 )edit

If catkin_make doesn't give an error, then I guess the build is working fine. Is it Visual Studio Code that is outputting the error? In that case, the include path is probably not set correctly. ros.h should be in /opt/ros/noetic/include/ros/ros.h.

miura gravatar image miura  ( 2021-05-19 08:27:17 -0500 )edit