Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem including rosbag.h

Hi there, trying to work with Rosbag CookBook I get following error when I try to catkin_make:

~/ws/src/main.cpp:98: error: undefined reference to 'rosbag::Bag::Bag()'
~/ws/src/main.cpp:149: error: undefined reference to 'rosbag::Bag::~Bag()'
~/ws/src/main.cpp:149: error: undefined reference to 'rosbag::Bag::~Bag()'
collect2: ld returned 1 exit status
make[2]: *** [/home/...] Error 1
make[1]: *** [...] Error 2
make: *** [all] Error 2
Invoking "make" failed

C++ code:

#include <ros/ros.h>
#include <rosbag/bag.h>
#include <rosbag/view.h>
#include <boost/foreach.hpp>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>

Regards, O3

Problem including rosbag.h

Hi there, trying to work with Rosbag CookBook I get following error when I try to catkin_make:

~/ws/src/main.cpp:98: error: undefined reference to 'rosbag::Bag::Bag()'
~/ws/src/main.cpp:149: error: undefined reference to 'rosbag::Bag::~Bag()'
~/ws/src/main.cpp:149: error: undefined reference to 'rosbag::Bag::~Bag()'
collect2: ld returned 1 exit status
make[2]: *** [/home/...] Error 1
make[1]: *** [...] Error 2
make: *** [all] Error 2
Invoking "make" failed

C++ code:

#include <ros/ros.h>
#include <rosbag/bag.h>
#include <rosbag/view.h>
#include <boost/foreach.hpp>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
using namespace rosbag;
rosbag::Bag bag;
//    bag.open("test.bag", rosbag::bagmode::Write);
//    bag.close();

Already put the following in CMakeLists:

find_package(rosbag REQUIRED)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
${rosbag_INCLUDE_DIRS}

Already put the following in package.xml:

<build_depend>rosbag</build_depend>
<run_depend>rosbag</run_depend>

Distro: Groovy (Installed via pre built packages.) Ubuntu: 12.04 LTS

me@mypc:~/ws$ env | grep ros

ROS_ROOT=/opt/ros/groovy/share/ros
ROS_PACKAGE_PATH=/opt/ros/groovy/share:/opt/ros/groovy/stacks
LD_LIBRARY_PATH=/opt/ros/groovy/lib
CPATH=/opt/ros/groovy/include
PATH=/opt/ros/groovy/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PYTHONPATH=/opt/ros/groovy/lib/python2.7/dist-packages
PKG_CONFIG_PATH=/opt/ros/groovy/lib/pkgconfig:/usr/local/lib/pkgconfig
CMAKE_PREFIX_PATH=/opt/ros/groovy
ROS_ETC_DIR=/opt/ros/groovy/etc/ros

and $rospack find rosbag:

/opt/ros/groovy/share/rosbag

Regards, O3

Problem including rosbag.h

Hi there, trying to work with Rosbag CookBook I get following error when I try to catkin_make:

~/ws/src/main.cpp:98: error: undefined reference to 'rosbag::Bag::Bag()'
~/ws/src/main.cpp:149: error: undefined reference to 'rosbag::Bag::~Bag()'
~/ws/src/main.cpp:149: error: undefined reference to 'rosbag::Bag::~Bag()'
collect2: ld returned 1 exit status
make[2]: *** [/home/...] Error 1
make[1]: *** [...] Error 2
make: *** [all] Error 2
Invoking "make" failed

C++ code:

#include <ros/ros.h>
#include <rosbag/bag.h>
#include <rosbag/view.h>
#include <boost/foreach.hpp>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
using namespace rosbag;
rosbag::Bag bag;
//    bag.open("test.bag", rosbag::bagmode::Write);
//    bag.close();

Already put the following in CMakeLists:

cmake_minimum_required(VERSION 2.8.0)
project(bagger)
find_package(Boost REQUIRED)
find_package(OpenCV REQUIRED)
find_package(rosbag REQUIRED)
find_package(catkin REQUIRED)

option(USE_GLUT "Use GLUT instead of OSMesa" ON)

if (${USE_GLUT})
set(${PROJECT_NAME}_export_libs ${PROJECT_NAME}_glut)
set(${PROJECT_NAME}_include_files ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/renderer_glut.h)
else()
set(${PROJECT_NAME}_export_libs ${PROJECT_NAME}_osmesa)
set(${PROJECT_NAME}_include_files ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/renderer_osmesa.h)
set(CATKIN_PACKAGE_BIN_DESTINATION share/${PROJECT_NAME}/bin)
set(CATKIN_PACKAGE_LIB_DESTINATION lib)
endif()

catkin_package(INCLUDE_DIRS include
  DEPENDS Boost
  DEPENDS rosbag
  LIBRARIES ${${PROJECT_NAME}_export_libs}
)

include_directories(include)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS}
 ${catkin_INCLUDE_DIRS}
 ${OpenCV_INCLUDE_DIRS}
 ${rosbag_INCLUDE_DIRS}
)
add_subdirectory(src)

# install the include folder
install(FILES ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/renderer.h
            ${${PROJECT_NAME}_include_files}
    DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}/
)

Already put the following in package.xml:

<build_depend>rosbag</build_depend>
<run_depend>rosbag</run_depend>

Distro: Groovy (Installed via pre built packages.) Ubuntu: 12.04 LTS

me@mypc:~/ws$ env | grep ros

ROS_ROOT=/opt/ros/groovy/share/ros
ROS_PACKAGE_PATH=/opt/ros/groovy/share:/opt/ros/groovy/stacks
LD_LIBRARY_PATH=/opt/ros/groovy/lib
CPATH=/opt/ros/groovy/include
PATH=/opt/ros/groovy/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PYTHONPATH=/opt/ros/groovy/lib/python2.7/dist-packages
PKG_CONFIG_PATH=/opt/ros/groovy/lib/pkgconfig:/usr/local/lib/pkgconfig
CMAKE_PREFIX_PATH=/opt/ros/groovy
ROS_ETC_DIR=/opt/ros/groovy/etc/ros

and $rospack find rosbag:

/opt/ros/groovy/share/rosbag

Regards, O3

Problem including rosbag.h

Hi there, trying to work with Rosbag CookBook I get following error when I try to catkin_make:

~/ws/src/main.cpp:98: error: undefined reference to 'rosbag::Bag::Bag()'
~/ws/src/main.cpp:149: error: undefined reference to 'rosbag::Bag::~Bag()'
~/ws/src/main.cpp:149: error: undefined reference to 'rosbag::Bag::~Bag()'
collect2: ld returned 1 exit status
make[2]: *** [/home/...] Error 1
make[1]: *** [...] Error 2
make: *** [all] Error 2
Invoking "make" failed

C++ code:

#include <ros/ros.h>
#include <rosbag/bag.h>
#include <rosbag/view.h>
#include <boost/foreach.hpp>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
using namespace rosbag;
rosbag::Bag bag;
//    bag.open("test.bag", rosbag::bagmode::Write);
//    bag.close();

CMakeLists:

cmake_minimum_required(VERSION 2.8.0)
project(bagger)
find_package(Boost FIND_PACKAGE(OpenGL)
find_package(PkgConfig REQUIRED)
find_package(ASSIMP QUIET)
find_package(rosbag REQUIRED)
if (NOT ASSIMP_FOUND)
  pkg_check_modules(ASSIMP assimp)
endif()
if (NOT ASSIMP_FOUND)
  message(WARNING "ASsimp not found, not building synthetic views")
endif()
if( ${ASSIMP_VERSION} STRGREATER "2.0.0" )
  message(STATUS "Found assimp v3")
  set(EXTRA_SOURCES)
  set(EXTRA_LIBRARIES assimp)
else()
  message(STATUS "Building assimp v3")
  set(ASSIMP_INCLUDE_DIRS ./assimp/include)
  aux_source_directory(./assimp/contrib/clipper EXTRA_SOURCES_clipper)
  aux_source_directory(./assimp/contrib/ConvertUTF EXTRA_SOURCES_ConvertUTF)
  aux_source_directory(./assimp/contrib/irrXML EXTRA_SOURCES_irrXML)
  aux_source_directory(./assimp/contrib/poly2tri/poly2tri/common EXTRA_SOURCES_poly2tri)
  aux_source_directory(./assimp/contrib/poly2tri/poly2tri/sweep EXTRA_SOURCES_poly2tri_sweep)
  aux_source_directory(./assimp/contrib/unzip EXTRA_SOURCES_unzip)
  aux_source_directory(./assimp/contrib/zlib EXTRA_SOURCES_zlib)
  aux_source_directory(./assimp/code EXTRA_SOURCES)
  set(EXTRA_SOURCES ${EXTRA_SOURCES} ${EXTRA_SOURCES_clipper} ${EXTRA_SOURCES_ConvertUTF} ${EXTRA_SOURCES_irrXML} ${EXTRA_SOURCES_poly2tri} ${EXTRA_SOURCES_poly2tri_sweep} ${EXTRA_SOURCES_unzip} ${EXTRA_SOURCES_zlib})
  set(EXTRA_LIBRARIES)
endif()

# create the 2d rendering library

add_library(${PROJECT_NAME}_2d renderer2d.cpp)
target_link_libraries(${PROJECT_NAME}_2d ${OpenCV_LIBRARIES})
install(TARGETS ${PROJECT_NAME}_2d
      DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)

# create the 3d rendering library
set(SOURCES model.cpp renderer3d.cpp utils.cpp)
include_directories(BEFORE ${ASSIMP_INCLUDE_DIRS})
include_directories(BEFORE ${rosbag_INCLUDE_DIRS})

find_package(OpenCV REQUIRED)
find_package(rosbag REQUIRED)
find_package(catkin REQUIRED)

option(USE_GLUT "Use GLUT instead of OSMesa" ON)

INCLUDE_DIRECTORIES(SYSTEM ${OpenCV_INCLUDE_DIR}
                       ${OPENGL_INCLUDE_DIR}
                       ${rosbag_INCLUDE_DIR}
)

if (${USE_GLUT})
set(${PROJECT_NAME}_export_libs   add_definitions(-DUSE_RENDERER_GLUT=1)

  find_package(GLUT)
  include_directories(SYSTEM ${GLUT_INCLUDE_DIR})

  # add a glut version of the renderer
  add_library(${PROJECT_NAME}_glut ${SOURCES}
                               renderer_glut.cpp
                               ${EXTRA_SOURCES}
  )
  target_link_libraries(${PROJECT_NAME}_glut ${EXTRA_LIBRARIES}
                                         ${OpenCV_LIBRARIES}
                                         ${OPENGL_LIBRARIES}
                                         ${GLUT_LIBRARIES}
                                         freeimage
  )
  install(TARGETS ${PROJECT_NAME}_glut
      DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  )
else()
  # add an OSMesa version of the renderer
  add_library(${PROJECT_NAME}_osmesa ${SOURCES}
                                 renderer_osmesa.cpp
                                 ${EXTRA_SOURCES}
  )

  target_link_libraries(${PROJECT_NAME}_osmesa ${EXTRA_LIBRARIES}
                                           ${OpenCV_LIBRARIES}
                                           OSMesa GLU
                                           freeimage
  )
  install(TARGETS ${PROJECT_NAME}_osmesa
      DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  )
endif()

# add an executable to render views to a file
ADD_EXECUTABLE(view_generator main.cpp)

SET_PROPERTY(TARGET view_generator PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX})
find_package(rosbag REQUIRED)

TARGET_LINK_LIBRARIES(view_generator ${EXTRA_LIBRARIES})

if (${USE_GLUT})
  target_link_libraries(view_generator ${PROJECT_NAME}_glut)
set(${PROJECT_NAME}_include_files ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/renderer_glut.h)
else()
set(${PROJECT_NAME}_export_libs   target_link_libraries(view_generator ${PROJECT_NAME}_osmesa)
set(${PROJECT_NAME}_include_files ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/renderer_osmesa.h)
set(CATKIN_PACKAGE_BIN_DESTINATION share/${PROJECT_NAME}/bin)
set(CATKIN_PACKAGE_LIB_DESTINATION lib)
endif()

catkin_package(INCLUDE_DIRS include
  DEPENDS Boost
  DEPENDS rosbag
  LIBRARIES ${${PROJECT_NAME}_export_libs}
target_link_libraries(view_generator ${PROJECT_NAME}_2d)

SET_TARGET_PROPERTIES(view_generator PROPERTIES
                                 OUTPUT_NAME view_generator
)

include_directories(include)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS}
   ${catkin_INCLUDE_DIRS}
   ${OpenCV_INCLUDE_DIRS}
   ${rosbag_INCLUDE_DIRS}
install(TARGETS view_generator
    DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
add_subdirectory(src)

# install the include folder
install(FILES ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/renderer.h
            ${${PROJECT_NAME}_include_files}
    DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}/
)
add some executables
add_subdirectory(apps)

Already put the following in package.xml:

<build_depend>rosbag</build_depend>
<run_depend>rosbag</run_depend>

Distro: Groovy (Installed via pre built packages.) Ubuntu: 12.04 LTS

me@mypc:~/ws$ env | grep ros

ROS_ROOT=/opt/ros/groovy/share/ros
ROS_PACKAGE_PATH=/opt/ros/groovy/share:/opt/ros/groovy/stacks
LD_LIBRARY_PATH=/opt/ros/groovy/lib
CPATH=/opt/ros/groovy/include
PATH=/opt/ros/groovy/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PYTHONPATH=/opt/ros/groovy/lib/python2.7/dist-packages
PKG_CONFIG_PATH=/opt/ros/groovy/lib/pkgconfig:/usr/local/lib/pkgconfig
CMAKE_PREFIX_PATH=/opt/ros/groovy
ROS_ETC_DIR=/opt/ros/groovy/etc/ros

and $rospack find rosbag:

/opt/ros/groovy/share/rosbag

Regards, O3