SLAM十四讲第二版ch6的未定义的引用问题

在使用slam十四讲第二版做题的时候发现,ch6编译问题,特此记录如下。

make时遇到问题如下:

对‘g2o::OptimizableGraph::Vertex::clone() const’未定义的引用
对‘g2o::OptimizableGraph::Edge::clone() const’未定义的引用
CMakeFiles/g2oCurveFitting.dir/build.make:143: recipe for target 'g2oCurveFitting' failed
make[2]: *** [g2oCurveFitting] Error 1

发现g20的问题,所以我们在FindG20.cmake文件中作如下修改:

建议不要直接复制粘贴,对比后复制进入。

​
# Find the header files

FIND_PATH(G2O_INCLUDE_DIRS g2o/core/base_vertex.h
  ${G2O_ROOT}/include
  $ENV{G2O_ROOT}/include
  $ENV{G2O_ROOT}
  /usr/local/include
  /usr/include
  /opt/local/include
  /sw/local/include
  /sw/include
  NO_DEFAULT_PATH
  )

# Macro to unify finding both the debug and release versions of the
# libraries; this is adapted from the OpenSceneGraph FIND_LIBRARY
# macro.

MACRO(FIND_G2O_LIBRARY MYLIBRARY MYLIBRARYNAME)

  FIND_LIBRARY("${MYLIBRARY}_DEBUG"
    NAMES "g2o_${MYLIBRARYNAME}_d"
    PATHS
    ${G2O_ROOT}/lib/Debug
    ${G2O_ROOT}/lib
    $ENV{G2O_ROOT}/lib/Debug
    $ENV{G2O_ROOT}/lib
    NO_DEFAULT_PATH
    )

  FIND_LIBRARY("${MYLIBRARY}_DEBUG"
    NAMES "g2o_${MYLIBRARYNAME}_d"
    PATHS
    ~/Library/Frameworks
    /Library/Frameworks
    /usr/local/lib
    /usr/local/lib64
    /usr/lib
    /usr/lib64
    /opt/local/lib
    /sw/local/lib
    /sw/lib
    NO_DEFAULT_PATH
    )
  
  FIND_LIBRARY(${MYLIBRARY}
    NAMES "g2o_${MYLIBRARYNAME}"
    PATHS
    ${G2O_ROOT}/lib/Release
    ${G2O_ROOT}/lib
    $ENV{G2O_ROOT}/lib/Release
    $ENV{G2O_ROOT}/lib
    NO_DEFAULT_PATH
    )

  FIND_LIBRARY(${MYLIBRARY}
    NAMES "g2o_${MYLIBRARYNAME}"
    PATHS
    ~/Library/Frameworks
    /Library/Frameworks
    /usr/local/lib
    /usr/local/lib64
    /usr/lib
    /usr/lib64
    /opt/local/lib
    /sw/local/lib
    /sw/lib
    NO_DEFAULT_PATH
    )

​

然后再make编译,可以通过。

 

 

你可能感兴趣的:(slam,slam)