ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

use ros header files in c++ project

asked 2018-02-16 10:59:19 -0600

lounis gravatar image


I am new to ROS. I want to include ros header files (for example #include <rosbag bag.h="">) in a c++ project. I do not want to create a node and start roscore. How can I include this header + other dependencies in a CMakeLists file ?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-02-16 12:49:51 -0600

lucasw gravatar image

See #q238955

catkin ( ) which makes use of CMake is the best supported way to go, otherwise you could do cmake on your own like:

find_package(roscpp REQUIRED)

Replace roscpp with whatever library you need.

pkg-config also can get ros libraries and includes.

edit flag offensive delete link more


@lucasw Thanks a lot. This is just what I was looking for.

lounis gravatar image lounis  ( 2018-02-16 14:20:03 -0600 )edit

using these lines in my CMakeList : cmake_minimum_required(VERSION 2.8.12) project(writeBag) find_package(roscpp REQUIRED) I get this error :CMake Error at CMakeLists.txt:3 (find_package): By not providing "Findroscpp.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package

lounis gravatar image lounis  ( 2018-02-19 07:37:25 -0600 )edit

../.. configuration file provided by "roscpp", but CMake did not find one.

Could not find a package configuration file provided by "roscpp" with any of the following names:


Add the installation prefix of "roscpp" to CMAKE_PREFIX_PATH or set..

lounis gravatar image lounis  ( 2018-02-19 07:38:14 -0600 )edit

I fixed this issue : I needed to source the ROS setup.bash file...

lounis gravatar image lounis  ( 2018-02-19 09:46:45 -0600 )edit

Question Tools



Asked: 2018-02-16 10:59:19 -0600

Seen: 1,490 times

Last updated: Feb 16 '18