# Trouble Including rosbag

Hello, I am trying to follow this tutorial: http://wiki.ros.org/rosbag/Code%20API... , but am running into errors with the inclusion of rosbag. When I try to run the example code, I get a jillion lines of errors all saying something like this: undefined reference to rosbag:somethingOrOther. However, I don't know what I'm doing wrong. I included rosbag/bag.h and rosbag/view.h in my C++ source file, and I believe I've linked the libraries correctly in my CMakelists file:

add_executable(rosbagger src/rosbagger.cpp) target_link_libraries(rosbagger ${catkin_LIBRARIES}) Anyone know whats going wrong? edit retag close merge delete ## Comments open the terminal and type ($ rospack depends1 <package_name>) in dependencies list do you see rosbag?

( 2014-01-08 18:31:19 -0600 )edit

Thanks I tried that and it said there were no dependcies so I recreated the package (with the correct dependcies) and now it seems to be working.

( 2014-01-12 07:03:42 -0600 )edit

Sort by » oldest newest most voted

You also have to specify rosbag as a dependency of your package correctly. The first example package I found where this is done is https://github.com/ros-perception/perception_pcl/tree/hydro-devel/pcl_ros. Have a look at the package package.xml and CMakeLists.txt files, search for "rosbag" and add the analogous (basically the same) lines to your package.

Also have a look at the related catkin wiki pages.

more

I have specified my dependencies as follows in the package.xml: <build_depend>rosbag</build_depend> <run_depend>rosbag</run_depend> However, I am still encountering the problem (I already had these lines in there; I just forgot to include them in the question)

( 2014-01-12 06:42:18 -0600 )edit

You probably forgot to insert "rosbag" under find_package(catkin REQUIRED COMPONENTS ...

( 2014-07-18 05:09:50 -0600 )edit

This was very helpful. I was missing the CMakeLists.txt part. Thanks!

( 2015-01-27 10:02:43 -0600 )edit