ROS编译catkin_make的时候报错找不到xxx.h头文件

报错内容:

/home/firefly/eai_ws/src/square/square_goal_service/src/service_server.cpp:3:53: fatal error: square_goal_service/square_goal_service.h: No such file or directory 没有那个文件或目录 #include

1、首先,查找头文件是否存在(include)

如果该头文件是存在的,那么查看是否告诉了编译器文件的路径!

2、其次,查看路径是否设置正确 (CMakeLists.txt)

catkin_package(
      LIBRARIES visionutil rosutil
      INCLUDE_DIRS include)
 
include_directories(
   include
   ${catkin_INCLUDE_DIRS})

3、最后,查看src源码中调用xxx.h文件方式是否正确

正确:

#include 

错误:

#include 

总结

以上三个步骤也是在ROS中创建.h头文件的流程:

  1. 创建头文件,具体文件路径如下include/ < name of package > / xxx.h,/include与/src同一层级,均在package下一级;

  2. 添加路径,修改CMakeLists.txt,在catkin_package和include_directories中分别添加INCLUDE_DIRS includeinclude

  3. 引用头文件,在应用代码中添加头文件,#include

你可能感兴趣的:(移动机器人专栏,自动驾驶,c++,c语言)