VSCode C++ IntelliSense works fine except for PCL (Point Cloud Library)
Asked Answered
T

2

7

On SO itself, there are already many questions about VSCode IntelliSense, e.g., que1, que2, que3, etc. However, they mainly talk about IntelliSense not working in general; not working for STL; and so on.

On the other hand, in my case, I'm already using VSCode C/C++ Extension by Microsoft and IntelliSense works fine for all the different in-built classes, functions, STLs, etc. But, when it comes to PCL (Point Cloud Library), somehow, mysteriously, IntelliSense doesn't work.

If you are familiar with PCL then must be knowing that most of its syntaxes are too big. And as the IntelliSense not working for it, there are very high chances of making typos if you don't pay close attention while typing every single character, e.g.,

pcl::PointCloud<pcl::PointXYZRGB>::Ptr point_cloud_ptr (new pcl::PointCloud<pcl::PointXYZRGB>);

In fact, auto-completion for even those variables and functions do not work--i.e., from the above example, I have to manually type every single character of point_cloud_ptr every time I want to use it.

So, how can I fix this? or it's not possible for PCL?

Note: I'm facing this issue on my Ubuntu 16 as well as on Ubuntu 18. I have installed PCL using sudo apt install libpcl-dev and the header files are located in /usr/include/ directory.

Thompkins answered 24/7, 2020 at 1:31 Comment(1)
I had asked the same question on the official GitHub issues page of the C/C++ extension by Microsoft and eventually, found the solution (but, not an ideal one). This is the link: github.com/microsoft/vscode-cpptools/issues/5843Thompkins
T
4

After trying out different things and getting help from Microsoft VSCode (and C/C++ extension) team on GitHub, it looks like the IntelliSense is not working probably because the extension is not able to find PCL headers.

In the case of Ubuntu, the PCL headers are generally stored at /usr/include/pcl-<version>. In my Ubuntu 18.04, I have pcl-1.8. So, ideally, adding "/usr/include/pcl-1.8/**" under "includePath" in c_cpp_properties.json file should work. e.g.

{
    "configurations": [
        {
            .
            .
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include/pcl-1.8/**"
            ],
            .
            .
            .
        }
    ],
    "version": 4
}

In "/usr/include/pcl-1.8/**", ** is for recursive search under /usr/include/pcl-1.8/ directory. However, by the time when I had posted the question (and I think as of today as well), it doesn't work. It's not able to go through the subdirectories under pcl-<version> directory. So, alternate solutions are below:


Solution 01: (Use this one if you want to apply changes only to the current project)

Open C/C++ Extension Configuration file: c_cpp_properties.json (On Linux, press Ctrl + Shift + P and select C/C++: Edit Configurations (JSON))

Now, as the recursive search is not working, an alternate way is to specify all the subdirectories under includePath:

{
    "configurations": [
        {
            .
            .
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include/eigen3",
                "/usr/include/pcl-1.8",
                "/usr/include/pcl-1.8/pcl",
                "/usr/include/pcl-1.8/pcl/2d",
                "/usr/include/pcl-1.8/pcl/apps",
                "/usr/include/pcl-1.8/pcl/common",
                "/usr/include/pcl-1.8/pcl/compression",
                "/usr/include/pcl-1.8/pcl/console",
                "/usr/include/pcl-1.8/pcl/features",
                "/usr/include/pcl-1.8/pcl/filters",
                "/usr/include/pcl-1.8/pcl/geometry",
                "/usr/include/pcl-1.8/pcl/impl",
                "/usr/include/pcl-1.8/pcl/in_hand_scanner",
                "/usr/include/pcl-1.8/pcl/io",
                "/usr/include/pcl-1.8/pcl/kdtree",
                "/usr/include/pcl-1.8/pcl/keypoints",
                "/usr/include/pcl-1.8/pcl/ml",
                "/usr/include/pcl-1.8/pcl/modeler",
                "/usr/include/pcl-1.8/pcl/octree",
                "/usr/include/pcl-1.8/pcl/outofcore",
                "/usr/include/pcl-1.8/pcl/people",
                "/usr/include/pcl-1.8/pcl/range_image",
                "/usr/include/pcl-1.8/pcl/recognition",
                "/usr/include/pcl-1.8/pcl/registration",
                "/usr/include/pcl-1.8/pcl/ros",
                "/usr/include/pcl-1.8/pcl/sample_consensus",
                "/usr/include/pcl-1.8/pcl/search",
                "/usr/include/pcl-1.8/pcl/segmentation",
                "/usr/include/pcl-1.8/pcl/stereo",
                "/usr/include/pcl-1.8/pcl/surface",
                "/usr/include/pcl-1.8/pcl/tracking",
                "/usr/include/pcl-1.8/pcl/visualization"
            ],
            .
            .
            .
        }
    ],
    "version": 4
}

Solution 02: (Use this one if you want to apply changes globally -- across all the projects)

As C/C++ Configuration File: c_cpp_properties.json is specific to each project, editing that will only apply changes to the current project. So, to apply changes across all the projects, one has to update settings.json and then c_cpp_properies.json.

Open settings.json and add the following text:

    "C_Cpp.default.includePath": [
        "/usr/include/eigen3",
        "/usr/include/pcl-1.8",
        "/usr/include/pcl-1.8/pcl",
        "/usr/include/pcl-1.8/pcl/2d",
        "/usr/include/pcl-1.8/pcl/apps",
        "/usr/include/pcl-1.8/pcl/common",
        "/usr/include/pcl-1.8/pcl/compression",
        "/usr/include/pcl-1.8/pcl/console",
        "/usr/include/pcl-1.8/pcl/features",
        "/usr/include/pcl-1.8/pcl/filters",
        "/usr/include/pcl-1.8/pcl/geometry",
        "/usr/include/pcl-1.8/pcl/impl",
        "/usr/include/pcl-1.8/pcl/in_hand_scanner",
        "/usr/include/pcl-1.8/pcl/io",
        "/usr/include/pcl-1.8/pcl/kdtree",
        "/usr/include/pcl-1.8/pcl/keypoints",
        "/usr/include/pcl-1.8/pcl/ml",
        "/usr/include/pcl-1.8/pcl/modeler",
        "/usr/include/pcl-1.8/pcl/octree",
        "/usr/include/pcl-1.8/pcl/outofcore",
        "/usr/include/pcl-1.8/pcl/people",
        "/usr/include/pcl-1.8/pcl/range_image",
        "/usr/include/pcl-1.8/pcl/recognition",
        "/usr/include/pcl-1.8/pcl/registration",
        "/usr/include/pcl-1.8/pcl/ros",
        "/usr/include/pcl-1.8/pcl/sample_consensus",
        "/usr/include/pcl-1.8/pcl/search",
        "/usr/include/pcl-1.8/pcl/segmentation",
        "/usr/include/pcl-1.8/pcl/stereo",
        "/usr/include/pcl-1.8/pcl/surface",
        "/usr/include/pcl-1.8/pcl/tracking",
        "/usr/include/pcl-1.8/pcl/visualization"
    ]

Open, c_cpp_properties.json and update includePath:

{
    "configurations": [
        {
            .
            .
            "includePath": [
                "${workspaceFolder}/**",
                "${default}"
            ],
            .
            .
            .
        }
    ],
  
  "version": 4
}

P.S. I had asked the same question on the official GitHub issues page of the C/C++ Extension by Microsoft and eventually, found the solution (but, not an ideal one) I mentioned above.

Here is the link for more info: https://github.com/microsoft/vscode-cpptools/issues/5843

Thompkins answered 7/3, 2021 at 0:9 Comment(0)
F
0

Because VSCode always told me that it could not find some dependency like pcl/PCLHeader.h. So I tried copying /usr/include/pcl-1.10/pcl to /usr/include/ and it worked.

Feral answered 9/4, 2022 at 8:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.