Ask Your Question

ros/ros.h No such file or directory

asked 2019-01-11 08:13:18 -0500

TristanNoctis gravatar image

I have been running ROS Melodic in my Ubuntu Bionic system. I already had a previous workspace called 'catkin_ws'. Recently, I tried to create another workspace which I named 'ros'. I then created a directory called 'first_package' inside the 'src' folder using the 'catkin_create_pkg' command. I then coded a small segment which I have attached below and named it hello.cpp inside the 'first_package' which I have attached below.

//This is the ROS standard of "hello, world" program//

//This header defined standard ROS classed//

int main(int argc, char **argv){
//Initialize the ROS system
ros::init(argc, argv, "hello_ros");

//Establish this program as ROS node
ros::NodeHandle nh;

//Send some output as log message

I have changed both the CMakeLists.txt and Package.xml accordingly, but I still receive this error. Could someone please resolve this issue. The error occurs when I use the command 'catkin_make'

This is the CMakeLists.txt file

cmake_minimum_required(VERSION 2.8.3)
find_package(catkin REQUIRED COMPONENTS roscpp)
add_executable(hello hello.cpp)
target_link_libraries(hello ${catkin_LIBRARIES})

The package.xml file is as follows,

<?xml version="1.0"?>
<package format="2">
  <description>The first_package package</description>
<maintainer email="danish@todo.todo">danish</maintainer>


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-01-11 15:16:23 -0500

gvdhoorn gravatar image

updated 2019-01-11 15:16:57 -0500


This is most likely your problem.

Even though you first do this:

find_package(catkin REQUIRED COMPONENTS roscpp)

You never update the include path with the contents of catkin_INCLUDE_DIRS, causing the compiler (or actually: the preprocessor) to not be able to find the headers.

You'll need to change that statement to at least something like the following:


Note that this is not really a ROS issue, but a CMake one.

edit flag offensive delete link more


You solved the issue! Can you be more precise as to why that part was needed to be added inside the include_directories()?

TristanNoctis gravatar image TristanNoctis  ( 2019-01-12 06:39:01 -0500 )edit

See the CMake documentation: include_directories().

As to why include directories need to be setup, that would be a generic programming question.

As to what catkin_INCLUDE_DIRS is: see the general Catkin documentation on ..

gvdhoorn gravatar image gvdhoorn  ( 2019-01-12 07:52:32 -0500 )edit

.. the ROS wiki here and the Include Paths and Library Paths section in particular.

Use ctrl+f and search for catkin_INCLUDE_DIRS on that page.

gvdhoorn gravatar image gvdhoorn  ( 2019-01-12 07:53:21 -0500 )edit

Thanks for that

TristanNoctis gravatar image TristanNoctis  ( 2019-01-12 08:35:02 -0500 )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-01-11 08:13:18 -0500

Seen: 2,988 times

Last updated: Jan 11 '19