# Problem creating a ROS package with the presence of external headers

Hi I am a PhD student and quite new to ROS trying to make a ROS package to use my Robot. The company who built the robot has also provided us some C++ libraries and codes, i.e. libRobot.h and libRobot.cc. Inside these codes there some functions from different classes that help us to read status of the robot and also send commands to it. For example:

int Rover::getSpeed ( Time & _timestamp,
float & _left,
float & _right
)

Get the speed of the tracks [in rad/s].

Parameters
[out] _timestamp the current timestamp [in s].
[out] _left the average speed of the front and rear left tracks [in rad/s].
[out] _right the average speed of the front and rear right tracks [in rad/s].
Returns
0 if success, an error code otherwise.


Now what I am trying to do is to create a package that executes some of this functions, for example to read the voltage of the battery, and publish the data as ROS messages. I put the *.h files in my_package/include and the *.cc files in my_package/ directories. I also set up my CMakeLists.txt as follows:

cmake_minimum_required(VERSION 2.8.3)
project(donkey_rover)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)
generate_messages(
DEPENDENCIES
std_msgs
)
catkin_package(
INCLUDE_DIRS include LIBRARIES donkey_rover
CATKIN_DEPENDS roscpp rospy std_msgs
DEPENDS system_lib
)
include_directories(
${catkin_INCLUDE_DIRS} ) add_executable(rovstate src/rovstate.cpp) target_link_libraries(rovstate${catkin_LIBRARIES}
)

add_dependencies(rovstate ${catkin_EXPORTED_TARGETS}) install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE )  When I put my header in my cpp file, (i.e. #include libRobot.h) the catkin_make process fails at the very last second: [ 98%] Built target navfn_node [ 98%] Built target navtest [100%] Built target global_planner [100%] Built target move_base_node [100%] Built target planner make[2]: *** [donkey_rover/CMakeFiles/rovstate.dir/src/rovstate.cpp.o] Error 1 make[1]: *** [donkey_rover/CMakeFiles/rovstate.dir/all] Error 2 make: *** [all] Error 2 Invoking "make -j2 -l2" failed  Do you have any idea how can I possibly solve the problem? Thank you very much in advance edit retag close merge delete ## 2 Answers Sort by » oldest newest most voted The solution to this problem can be find in this question. more For the next time, please try to find the relevant lines where the error is detailed. From your post, we only see there is an error. However, there are several problems with your CMakeLists.txt. You need to tell the compiler where to find the headers you include. So adapt the following lines in your CMakeLists.txt from: include_directories(${catkin_INCLUDE_DIRS}
)


to

include_directories(
include
\${catkin_INCLUDE_DIRS}
)


But I guess you will also need to add the library source file to the add_executable call, so:

add_executable(rovstate src/rovstate.cpp src/libRobot.cc)

more