ROS noetic, fatal error: ros/ros.h: No such file or directory
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">
<name>infoexc</name>
<version>0.0.0</version>
<description>The infoexc package</description>
<maintainer email="cnr@todo.todo">cnr</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
and this is my CMakeLists.txt file:
cmake_minimum_required(VERSION 3.0.2)
project(infoexc)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)
include_directories(
${catkin_INCLUDE_DIRS}
)
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!
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.
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.