报错内容:
/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 <square_goal_service/square_goal_service.h>
1、首先,查找头文件是否存在(include)
如果该头文件是存在的,那么查看是否告诉了编译器文件的路径!
2、其次,查看路径是否设置正确 (CMakeLists.txt)
catkin_package(
LIBRARIES visionutil rosutil
INCLUDE_DIRS include)
include_directories(
include
${catkin_INCLUDE_DIRS})
3、最后,查看src源码中调用xxx.h文件方式是否正确
正确:
#include <name_of_package/header_file.h>
错误:
#include <header_file.h>
总结
以上三个步骤也是在ROS中创建.h头文件的流程:
-
创建头文件,具体文件路径如下include/ < name of package > / xxx.h
,/include与/src同一层级,均在package下一级;
-
添加路径,修改CMakeLists.txt,在catkin_package和include_directories中分别添加INCLUDE_DIRS include
和include
;
-
引用头文件,在应用代码中添加头文件,#include <name_of_package/header_file.h>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)