Ask Your Question

ros/ros.h: No such file or directory

asked 2021-09-15 09:02:46 -0500

lzyr gravatar image

updated 2021-09-16 03:48:54 -0500

Hello, I'm new to ROS, and I have some trouble with my first file. When I include: #include "ros/ros.h" in VSCode, it says "ros/ros.h: No such file or directoy". I'm using ROS Melodic on Ubuntu 18.04.

Here is my CMakeLists.text:

cmake_minimum_required(VERSION 3.0.2)
find_package(catkin REQUIRED COMPONENTS
add_executable(hello src/helloworld.cpp)
target_link_libraries(hello ${catkin_LIBRARIES})


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



 <!-- Other tools can request additional information be placed here -->



"configurations": [
        "browse": {
            "databaseFilename": "",
            "limitSymbolsToIncludedHeaders": true,
            "path": [
    "includePath": [
            "name": "ROS",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64",
            "compilerPath": "/usr/bin/gcc"
    "version": 4


    "version": "2.0.0",
    "tasks": [
            "label": "catkin_make:debug",
            "args": [
                "-I", "/opt/ros/melodic/include",
                "-I", "${workspaceFolder}"
            "group": {
            "kind": "build",
            "isDefault": true
    "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "shared",
        "showReuseMessage": true,
        "clear": false

And I have found "ros" directory using cd /opt/ros/melodic/include and ls. I'm quite confused now. Thanks for your help.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2021-09-16 01:59:26 -0500

Ranjit Kathiriya gravatar image

updated 2021-09-17 03:51:22 -0500

I think You forgot to include your workspace path, in c_cpp_properties For more ref: have a look at this answer, CPP solution is given #q382798

edit flag offensive delete link more


I add this line in both c_cpp_propertities.json and tasks.json, but there is the same error.

lzyr gravatar image lzyr  ( 2021-09-16 03:46:06 -0500 )edit

When I include: #include "ros/ros.h" in VSCode,

Can you please try to run the program via the terminal? Does it work fine?

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2021-09-16 03:49:46 -0500 )edit

Can you please confirm that you have included path in this section in c_cpp_properties -> includePath ?

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2021-09-16 03:54:31 -0500 )edit

Yeah, I add the line: "/home/dell/catkin_ws/src/**" to c_cpp_properties in "includePath", but this error happens again. The program works fine via the terminal, though.

lzyr gravatar image lzyr  ( 2021-09-17 03:20:04 -0500 )edit

Ohhh! I am sorry,


Open your devel folder and find the include folder you will solve this.

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2021-09-17 03:25:34 -0500 )edit

Do you mean adding the line "${workspaceFolder}/devel/include/**" ? In fact, I don't have a "include" directory in /devel.

lzyr gravatar image lzyr  ( 2021-09-17 03:39:34 -0500 )edit

Yes, but No. $ and {} things, for example, my workspace name is ws_ros.

"~/ws_ros/devel/include" - Directly,

One more thing to note you have to give include path only so no /**, You can also have a look by opening your workspace/devel folder where the include folder is you just have to add that path in c_cpp_propertities.json.

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2021-09-17 03:50:33 -0500 )edit

Unfortunately, it fails to work. I guess the point is, how vscode include header files from a third library.

lzyr gravatar image lzyr  ( 2021-09-18 03:55:07 -0500 )edit

answered 2021-09-15 18:16:10 -0500

Mike Scheutzow gravatar image

Did you try putting vscode in the search box at the top of this page?

There is a #q256565 "How to add ROS to path in VS Code?" on the first page of results.

edit flag offensive delete link more


Yeah, I followed these posts and set my C_cpp.properities.json and tasks.json. Still, this error arises.

lzyr gravatar image lzyr  ( 2021-09-15 21:35:53 -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



Asked: 2021-09-15 09:02:46 -0500

Seen: 56 times

Last updated: Sep 17