Cannot find header file of custom service: No such file or directory
Hi all, I'm having a package with some custom services, everything worked fine. But when others try to build my package with "catkin_make" command, it says that "No such file or directory" when it meets the line
#include <my_package/MyService.h>
I added the following line to CMakeLists.txt:
add_dependencies(foo my_package_generate_messages_cpp)
But it didn't work. I think above line only work if only the executables include header files. But in my case, I have some header files that declare libraries also use the custom services. So I commented all the files that included this line in CMakeLists.txt and built the services alone, then I uncommented those files and catkin_make again, everything were back to normal. It seems like the compiler didn't found the header files in directory my_package/devel/include.
Here is my CMakeList.txt:
cmake_minimum_required(VERSION 3.0.2)
project(my_behavior_tree)
find_package(catkin REQUIRED COMPONENTS
roscpp
behaviortree_cpp_v3
message_generation
actionlib
move_base_msgs
)
add_service_files(
FILES
TakePackage.srv
SetDeliveryPoint.srv
GoToPose.srv
PauseRequest.srv
CruiseMode.srv
ChooseMode.srv
)
add_message_files(
FILES
OfficePose.msg
DeliveryPose.msg
RobotStatus.msg
)
generate_messages(
DEPENDENCIES
)
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${BEHAVIOR_TREE_LIBRARY}
CATKIN_DEPENDS roscpp message_runtime
DEPENDS
)
include_directories(
include
${catkin_INCLUDE_DIRS}
)
# Declare a C++ library
add_library(my_bt_lib src/control/delivery.cpp src/control/charge.cpp
src/control/cruise.cpp
src/reception/music.cpp src/reception/time_keeping.cpp
src/reception/direction.cpp)
# Specify libraries to link a library or executable target against
target_link_libraries(my_bt_lib ${BEHAVIOR_TREE_LIBRARY})
add_executable(move_robot src/move_robot.cpp src/control/delivery.cpp
src/control/charge.cpp src/reception/direction.cpp
src/reception/music.cpp src/reception/time_keeping.cpp
src/control/cruise.cpp)
target_link_libraries(move_robot ${catkin_LIBRARIES})
Can you share your Cmake?
I just update the question, please take a look. Thank you very much.
add this line at the end of your Cmake and try it again: