Ask Your Question
1

trouble compiling rospackage with g2o

asked 2013-07-23 00:09:19 -0500

apalomer gravatar image

Hi all!

I am trying to build a basic ros package to do (and optimize) a graph using g2o and data from a robot. The problem is that I can not get to compile even an easy module where I just put few vertices and edges manually (let's say a square) in order to test if I am using propperly the g2o library. I want the latest g2o so I downladed (https://github.com/RainerKuemmerle/g2o) and installed it by myself follwing its intructions.

The errors I get when I compile are the following:

  • /usr/local/include/g2o/core/block_solver.hpp:446: undefined reference to `g2o::get_monotonic_time()'

  • /usr/local/include/g2o/core/batch_stats.h:73: undefined reference to `g2o::G2OBatchStatistics::_globalStats'

  • /usr/local/include/g2o/solvers/csparse/linear_solver_csparse.h:126: undefined reference to `g2o::csparse_extension::cs_cholsolsymb(cs_sparse const, double, cs_symbolic const, double, int*)'

  • /usr/local/include/g2o/solvers/csparse/linear_solver_csparse.h:176: undefined reference to `g2o::MarginalCovarianceCholesky::~MarginalCovarianceCholesky()'

  • /usr/local/include/g2o/solvers/csparse/linear_solver_csparse.h:173: undefined reference to `g2o::MarginalCovarianceCholesky::MarginalCovarianceCholesky()'

  • /usr/local/include/g2o/solvers/csparse/linear_solver_csparse.h:174: undefined reference to `g2o::MarginalCovarianceCholesky::setCholeskyFactor(int, int, int, double, int)'

  • /usr/local/include/g2o/solvers/csparse/linear_solver_csparse.h:175: undefined reference to `g2o::MarginalCovarianceCholesky::computeCovariance(double**, std::vector<int, std::allocator<int=""> > const&)'

  • /usr/local/include/g2o/solvers/csparse/linear_solver_csparse.h:176: undefined reference to `cs_nfree'

I obviously skept the parts of the error message where it points to my code.

My CMakeList.txt is:

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)

rosbuild_init()
find_package(Eigen REQUIRED)
include_directories(${EIGEN_INCLUDE_DIRS})
add_definitions(${EIGEN_DEFINITIONS})

set(g2o_DIR /usr/local/bin/g2o)
include_directories(/usr/local/include/EXTERNAL/csparse)
include_directories(${G2O_INCLUDE_DIRS})

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

rosbuild_add_executable(g2o_mvm src/g2o_mvm.cpp)

Thank you very much!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-07-23 03:00:05 -0500

juandhv gravatar image

G2O_INCLUDE_DIRS is not defined previously, as mention. So, we have corrected as follows:

SET(G2O_LIBS g2o_cli g2o_ext_freeglut_minimal g2o_simulator g2o_solver_slam2d_linear g2o_types_icp g2o_types_slam2d g2o_core g2o_interface g2o_solver_csparse g2o_solver_structure_only g2o_types_sba g2o_types_slam3d g2o_csparse_extension g2o_opengl_helper g2o_solver_dense g2o_stuff g2o_types_sclam2d g2o_viewer g2o_ext_csparse g2o_parser g2o_solver_pcg g2o_types_data g2o_types_sim3 cxsparse )

rosbuild_add_executable(g2o_mvm src/g2o_mvm.cpp) target_link_libraries(g2o_mvm ${G2O_LIBS})

In ubuntu, g2o can be installed directly from the repository (ros-<distro>-libg2o), however we have built it from the source code.

edit flag offensive delete link more

Comments

Thanks! That totally solved the problem!

apalomer gravatar imageapalomer ( 2013-07-24 00:22:33 -0500 )edit
0

answered 2013-07-23 01:12:15 -0500

gvdhoorn gravatar image

updated 2013-07-23 01:15:57 -0500

You're not linking your executable with the g2o library. The errors you get come from the linker, which is informing you it cannot find any of the symbols you are referencing. Something along the lines of

link_directories (/path/to/where/you/installed/g2o/libraries)
target_link_libraries (g2o_mvm some_g2o_library)

should solve this.


Edit: where does the G2O_INCLUDE_DIRS variable come from? You're adding it to your include directories, but it doesn't seem to get set by any earlier statements.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-07-23 00:09:19 -0500

Seen: 2,453 times

Last updated: Jul 23 '13