Catkin unable to include custom libraries
报错内容:
/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>
首先查找头文件(file)是否存在
You should create a folder named include/ < name of package > / (include/proj_utils in your case) where you put all the header files (*.hpp) of the package.
但是实际上该文件是存在的,那么查看是否告诉了编译器文件的路径!
其次路径是否设置正确(directory)
Then the package that exports the library should have the following in the CMakeLists to be able to export the header files:
catkin_package(
LIBRARIES visionutil rosutil
INCLUDE_DIRS include)
include_directories(
include
${catkin_INCLUDE_DIRS})

再次在src源码中调用xx.h文件方式是否正确
正确:
#include <name_of_package/header_file.h>
错误:
#include <header_file.h>
以上三个步骤也是在ROS中创建.h头文件的流程!
1.创建头文件,具体文件路径如下include/ < name of package > / (include/proj_utils in your case) ,/include与/src同一层级均在package下一级;
2.添加路径,修改CMakeLists,在catkin_package和include_directories中分别添加INCLUDE_DIRS include和include;
3.引用头文件,在应用代码中添加头文件,#include <name_of_package/header_file.h>
参考文献:
https://answers.ros.org/question/195467/catkin-unable-to-include-custom-libraries/
480




被折叠的 条评论
为什么被折叠?



