简体   繁体   中英

c++, g2o (Graph-Framework), qcreator, undefined reference to methods

I'm trying to use the g2o library in a c++ project. I installed the library in two systems

  • OpenSuse - dependencies through zypper install, g2o by compiling according to directions
  • Ubuntu - all dependencies through apt-get, g2o by compiling according to directions

My .pro file includes these, in order to link to the .so libaries:

INCLUDEPATH +=   /home/rhun/data/Coding/g2o/trunk/lib/
LIBS        += -L/home/rhun/data/Coding/g2o/trunk/lib/
LIBS += -lg2o_calibration_odom_laser
LIBS += -lg2o_cli
LIBS += -lg2o_core
LIBS += -lg2o_csparse_extension 
LIBS += -lg2o_ext_freeglut_minimal
LIBS += -lg2o_interface
LIBS += -lg2o_parser
LIBS += -lg2o_simulator
LIBS += -lg2o_solver_csparse
LIBS += -lg2o_solver_dense
LIBS += -lg2o_solver_eigen
LIBS += -lg2o_solver_pcg
LIBS += -lg2o_solver_slam2d_linear
LIBS += -lg2o_solver_structure_only
LIBS += -lg2o_stuff
LIBS += -lg2o_tutorial_slam2d
LIBS += -lg2o_types_data
LIBS += -lg2o_types_icp
LIBS += -lg2o_types_sba
LIBS += -lg2o_types_sclam2d
LIBS += -lg2o_types_sim3
LIBS += -lg2o_types_slam2d
LIBS += -lg2o_types_slam3d
INCLUDEPATH += /usr/include/suitesparse/  
INCLUDEPATH += /home/rhun/data/Coding/g2o/tags/before-github-sync/
INCLUDEPATH += /home/rhun/data/Coding/g2o/tags/before-github-sync/EXTERNAL/eigen3/
INCLUDEPATH += /home/rhun/data/Coding/g2o/trunk/build/

When I try to #include things, I can see everything in the drop down menu.

However, I keep getting this message:

error: undefined reference to 'g2o::SparseOptimizer::setMethod(g2o::SparseOptimizer::Method)'

I'm stuck for hours here. Could you please shed some light? Thank you! :)

OK, I downloaded the version of g2o that ships here (http://openslam.org/g2o.html) , but it didn't work for me. Once I downloaded the version that ships through github , problems were gone. The github version is the most up-to-date version, and also patches are applied whenever needed by the creators, and that means that also during installation no tweaking of makefiles was needed.

The only "problem" is that, this new version introduced some changes, which makes some examples found online a bit outdated, but nothing scary ;) (it was not difficult to get up and running, by looking and old tutorials, new samples, documentation and source code)

I will copy here the answer of Rainer Kuemmerle (author of g2o), found here

Indeed the API changed quite a bit which leads to the fact, that the code-case from OpenSLAM is not compatible with the current code hosted here on github. There is not much we can do about this, adding new features required us to break the old API. The best would be to adapt the code that uses g2o. For example, setMethod has to be replaced by setting the corresponding OptimizationAlgorithm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM