ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How to setup Intelisense on VS Code for ROS C++

asked 2018-02-09 19:43:02 -0500

horseatinweeds gravatar image

updated 2018-02-09 20:26:19 -0500

jayess gravatar image

#include "ros/ros.h" is even underlined in green. I have this added to the c_cpp_properties.json file. I also installed the ROS extension (which I'm not sure does anything).

    "configurations": [
            "browse": {
                "databaseFilename": "",
                "limitSymbolsToIncludedHeaders": true,
                "path": [
            "includePath": [
            "name": "Linux",
            "intelliSenseMode": "clang-x64"
    "version": 3

When I hover over top of the include, it gives me an error:

#include errors detected. Please update your includePath. IntelliSense features for this translation unit (/home/ben/workspaces/ROS/ackermann/src/twist_to_ackermann-1/src/twist_to_ackermann.cpp) will be provided by the Tag Parser.
cannot open source file "x86intrin.h" (dependency of "ros/ros.h")

Everything else ROS works... This in Ubuntu 16.04 and ROS Kinetic.

edit retag flag offensive close merge delete


I meet the same problem. I find "x86intrin.h" in /usr/lib/gcc/x86_64-linux-gnu/5/include. Add this path to c_cpp_properties.json and #include "ros/ros.h" is OK.

Amos gravatar image Amos  ( 2018-03-29 00:21:49 -0500 )edit

Have you solved this problem ?

N.N.Huy gravatar image N.N.Huy  ( 2020-04-09 12:58:10 -0500 )edit

There are suggested answers to this problem under another question.

hansolo gravatar image hansolo  ( 2020-10-02 09:18:14 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2018-02-10 03:01:34 -0500

gvdhoorn gravatar image

It's probably doable to set this up manually, but I would recommend to take a look at wiki/IDEs - Visual Studio Code (VSCode). It has a link to an extension that should take care of all of this for you.

edit flag offensive delete link more



"The extension does not require additional configuration" is the biggest lie ever!

Mehdi. gravatar image Mehdi.  ( 2021-05-11 09:28:38 -0500 )edit

Thanks for the feedback.

It would be more valuable if you could give your feedback to Microsoft, on their issue tracker.

Your comment here will most likely not be read by many people.

gvdhoorn gravatar image gvdhoorn  ( 2021-05-11 09:31:55 -0500 )edit

As Samarth mentioned in his answer, this blog post really helps getting it setup correctly.

Mehdi. gravatar image Mehdi.  ( 2021-05-11 09:47:43 -0500 )edit

answered 2021-08-05 12:34:59 -0500

Madhukar gravatar image

This works for me:

  1. In .vscode folder and in c_cpp_properties.json file add "/opt/ros/distribution_name/include" in includePath, including quotes. Change "distribution_name" to your ROS distribution.
  2. Restart vs code.
edit flag offensive delete link more

answered 2020-12-14 14:17:17 -0500

The ROS extension mentioned in wiki/IDEs includes a task to update the c_cpp_properties.json (adding ROS paths to includePath), but in my experience that feature is brittle.

It is much more robust to let catkin handle that by getting CMake to export compile_commands.json during the build process. Then you can point C++ IntelliSense to that compile_commands.json as an alternative to modifying the includePath. VSCode reference

More details (copied from my here):

This blog post by Erdal gives nice step-by-step instructions.

I had to make one change, though: Instead of creating the new catkin_make task, I used the default catkin: make task that the VSCode ROS extension automatically creates.

For IntelliSense to work, CMake in the catkin: make task needs to be configured to generate compile_commands.json, as the blog mentions. But the catkin: make task command cannot be edited. However, it simply runs catkin build (or catkin_make, whichever command you normally use to build ROS workspaces) under the hood. So I pre-configure catkin for my ROS workspace like so:

bash $ cd catkin_ws $ catkin config -a --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=1

Note that I use catkin-tools, not the simple catkin that ships with ROS.

The above command caches the CMAKE_EXPORT_COMPILE_COMMANDS CMake argument in the catkin configuration. As mentioned in the blog, this CMake argument causes it to create compile_commands.json in catkin_ws/build/<package_name>/. If you point IntelliSense to this file using the compileCommands field in c_cpp_properties.json as mentioned in the blog, everything works.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-02-09 19:43:02 -0500

Seen: 15,188 times

Last updated: Dec 14 '20