g2o编译出现的问题及解决办法 By not providing "FindG2O.cmake" in CMAKE_MODULE_PATH this project has

**

在安装完该g2o之后 运行一些程序 如高翔的ch6 代码会出现如下错误

**

CMake Warning at CMakeLists.txt:10 (FIND_PACKAGE):
  By not providing "FindG2O.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "G2O", but
  CMake did not find one.

  Could not find a package configuration file provided by "G2O" with any of
  the following names:

    G2OConfig.cmake
    g2o-config.cmake

  Add the installation prefix of "G2O" to CMAKE_PREFIX_PATH or set "G2O_DIR"
  to a directory containing one of the above files.  If "G2O" provides a
  separate development package or SDK, be sure it has been installed.

解决方式很简单:
主要是CMakeLists.txt上要修改几行代码

本来是这样的就会报错,

list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ) 
find_package(G2O REQUIRED) 
include_directories( 
${G2O_INCLUDE_DIRS} ) 

修改为:

list( APPEND CMAKE_MODULE_PATH /home/×××/g2o/cmake_modules ) 
set(G2O_ROOT /usr/local/include/g2o) 
find_package(G2O REQUIRED) 
include_directories( 
${G2O_INCLUDE_DIRS} ) 

然后再cmake便不会出现问题了。

主要原因就是原始代码中

${PROJECT_SOURCE_DIR}/cmake

是ch6中的文件含有的cmake文件夹中FindG2O.cmake在你的文件夹不存在,只要把list那行路径改到FindG2O.cmake存在的文件夹就行。

你可能感兴趣的:(软件)