在使用catkin_make编译代码时,出现错误如下
/home/hx/WorkSpace/topic_ws/src/learning_topic/src/pose_subscriber.cpp:13:10: fatal error: pcl/io/pcd_io.h: 没有那个文件或目录
#include <pcl/io/pcd_io.h>
1.首先确认头文件是否存在
2.如果文件不存在,。。。。那就去找吧,如果存在此文件,找到文件路径,并在VSCode中c_cpp_properties.json中,添加这个头文件路径
3。这个时候VScode中不会出现红色的波浪线了,但是使用catkin_make还是会报错
4.修改 CMakeList.txt的内容,如下
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
INCLUDE_DIRS include
LIBRARIES learning_topic
# CATKIN_DEPENDS geometry_msgs roscpp rospy std_msgs turtlesim
# DEPENDS system_lib
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
include
${catkin_INCLUDE_DIRS}
include /usr/include/pcl-1.8/
include /usr/include/eigen3/
)
再将头文件路径,放在include_directories中,然后再编译