Hi all,
I am facing a compilation problem when I try to include a service.h file in a node located in another package.
Here is the architecture :
rosfond/
src/
my_nodes.cpp
include/
...
srv/
my_service.srv
hmi/
src/
my_other_nodes.cpp
include/
...
I want to use `my_service` in the `hmi` package, and especially include `my_service.h` in `my_other_nodes.cpp`. For that,
I wrote at the beginning of `my_other_nodes.cpp` `#include "rosfond/my_service.h"`.
I also use `my_service` in `my_nodes`.
When I try to compile my whole workspace, it fails. However, if I compile only `rosfond`, it works. So the problem seems to be related to how I include/link `my_service` in `my_other_nodes` and in the hmi's `CMakeLists.txt`.
Here are the `CMakeLists.txt` and the `package.xml` file of each package :
cmake_minimum_required(VERSION 2.8.3)
project(rosfond)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
)
add_service_files(DIRECTORY srv FILES my_service.srv)
generate_messages(DEPENDENCIES std_msgs)
catkin_package(
INCLUDE_DIRS include
# LIBRARIES rosfond
CATKIN_DEPENDS roscpp rospy std_msgs
# DEPENDS system_lib
)
include_directories(
${catkin_INCLUDE_DIRS}
include
)
add_executable(my_nodes src/my_nodes.cpp)
target_link_libraries(my_nodes
${catkin_LIBRARIES}
)
+++++++++++++++++++++++++++++++++++++++++++++++
rosfond 0.0.0 The rosfond package ghost TODO catkin roscpp rospy std_msgs roscpp rospy std_msgs
+++++++++++++++++++++++++++++++++++++++++++++++
cmake_minimum_required(VERSION 2.8.3)
project(hmi)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
)
generate_messages(DEPENDENCIES std_msgs)
catkin_package(
INCLUDE_DIRS include
# LIBRARIES hmi
CATKIN_DEPENDS roscpp rospy std_msgs
# DEPENDS system_lib
)
include_directories(
${catkin_INCLUDE_DIRS}
include
)
add_executable(my_other_nodes src/my_other_nodes.cpp)
target_link_libraries(my_other_nodes
${catkin_LIBRARIES}
)
+++++++++++++++++++++++++++++++++++++++++++++++
hmi 0.0.0 The hmi package ghost TODO catkin roscpp rospy std_msgs rosfond rosfond roscpp rospy std_msgs
++++++++++++++++++++++++++++++++++++++++++++++++
The error message is : `my_other_nodes.cpp : rosfond/my_service.h: No such file or directory`.
Thanking you in advance for your answers,
roach
↧