ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
The error you quote is basically a linking error, meaning the linker can't find the library that provides the binary code for a particular symbol you use.
In this case you're not linking against the rosbag
libraries.
You'll need to make sure that you've added rosbag
to the find_package(catkin COMPONENTS ..)
(or a regular find_package(..)
) line in your CMakeLists.txt
, and that you've added the appropriate target_link_libraries(..)
that links your executable against the rosbag
library.
As this is all CMake, you'll want to keep the CMake Documentation at hand.
2 | No.2 Revision |
The error you quote is basically a linking error, meaning the linker can't find the library that provides the binary code for a particular symbol you use.
This is not a ROS problem.
In this case you're not linking against the rosbag
libraries.
You'll need to make sure that you've added rosbag
to the find_package(catkin COMPONENTS ..)
(or a regular find_package(..)
) line in your CMakeLists.txt
, and that you've added the appropriate target_link_libraries(..)
that links your executable against the rosbag
library.
As this is all CMake, you'll want to keep the CMake Documentation at hand.
3 | No.3 Revision |
The error you quote is basically a linking error, meaning the linker can't find the library that provides the binary code for a particular symbol you use.
This is not a ROS problem.
In this case you're not linking against the rosbag
libraries.
You'll need to make sure that you've added rosbag
to the find_package(catkin COMPONENTS ..)
(or a regular find_package(..)
) line in your CMakeLists.txt
, and that you've added the appropriate target_link_libraries(..)
that links your executable against the rosbag
library.
As this is all CMake, you'll want to keep the CMake Documentation at hand.
Edit:
@gvdhoorn I made CMakeLists.txt as you suggested: like below:
cmake_minimum_required (VERSION 2.6) project (tutorial) find_package(catkin REQUIRED rosbag) set(SOURCES sampleOne.cpp) add_executable(test ${SOURCES}) target_link_libraries(test)
Two things here:
rosbag
, there is no need for find_package(catkin ..)
, just use find_package(rosbag REQUIRED)
directly.target_link_libraries(..)
in there, but you don't actually link your test
binary against any libraries.The last point is actually why you're still getting errors.
both source code and CMakelists.txt is in a directory named "cmake_example".
Now I ran
cmake . make
Please don't use in-source builds with CMake.
which does not product executable named "test"
but if I remove first line of source code
rosbag::Bag bag;
it does create executable named "test", which I can happily execute.
Which makes sense, as you're not actually linking against any of rosbag
's libraries.
Try the following:
cmake_minimum_required(VERSION 2.6)
project (tutorial)
find_package(rosbag REQUIRED)
include_directories(${rosbag_INCLUDE_DIRS})
add_executable(test sampleOne.cpp)
target_link_libraries(test ${rosbag_LIBRARIES})
That will probably work.