Rosanswers logo

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 > 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)

# 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)

find_package(Eigen REQUIRED)

set(g2o_DIR /usr/local/bin/g2o)

#set the default path for built executables to the "bin" directory
#set the default path for built libraries to the "lib" directory

rosbuild_add_executable(g2o_mvm src/g2o_mvm.cpp)

Thank you very much!

Originally posted by apalomer on ROS Answers with karma: 318 on 2013-07-23

Post score: 1


1 Answer 1


Rosanswers logo

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--libg2o), however we have built it from the source code.

Originally posted by juandhv with karma: 16 on 2013-07-23

This answer was ACCEPTED on the original site

Post score: 0

Original comments

Comment by apalomer on 2013-07-24:
Thanks! That totally solved the problem!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.