问题
PCL库是ROS框架自带的点云处理库,可以通过find_package(PCL REQUIRED)在CMakeLists.txt中导入,但是vscode却无法识别,出现问题如下:
 
 注意,本文解决方案仅限Ubuntu!
解决方案
- 打开工程路径下的.vscode文件夹(一般是自动隐藏的,Ctrl+H显示隐藏)
- 设置c_cpp_properties.json文件如下:
  
{"configurations": [{"name": "Linux","includePath": ["${workspaceFolder}/**","/usr/include/pcl-1.8", //pcl path,  replace version with yours],"defines": [],"compilerPath": "/usr/bin/clang","cStandard": "c11","cppStandard": "c++11", // version >==c++11"intelliSenseMode": "linux-clang-x64"}],"version": 4
}
就是在includePath中加入pcl的路径,若是通过ROS装的,一般都会在/usr/include/中。若不是,请按照自己安装的路径修改。
其他问题及解决方案
已经按照上述步骤操作,但是io的库仍然无法导入。
 pcd_io.h无法导入:
 
 这是由于Eigen3依赖未导入的原因导致的,继续修改c_cpp_properties.json文件如下:
```cpp
{"configurations": [{"name": "Linux","includePath": ["${workspaceFolder}/**","/usr/include/eigen3",  // eigen3 path"/usr/include/pcl-1.8", //pcl path,  replace version with yours],"defines": [],"compilerPath": "/usr/bin/clang","cStandard": "c11","cppStandard": "c++11", // version >==c++11"intelliSenseMode": "linux-clang-x64"}],"version": 4
}

 看着舒服多了