COULD NOT FIND A PACKAGE,CONFIGURATION FILE PROVIDED BY “G2O” ,G2OCONFIG.CMAKE,G2O-CONFIG.CMAKE
在学习slam十四讲的时候,成功安装编译了g2o,但是在运行g2o_curve_fitting代码时出现错误,提示如下:
CMake Error at CMakeLists.txt:8 (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.
这时需要在cmakelist文件中添加几行代码,添加代码如下:
list(APPEND CMAKE_MODULE_PATH /XXX/g2o/cmake_modules)
set(G2O_ROOT /XXX/g2o)
find_package( G2O REQUIRED )
include_directories(
${G2O_INCLUDE_DIRS}
“/usr/include/eigen3”
)
/XXX/g2o 是你的g2o安装目录,如果不知道自己的安装录取,可以在lunix主文件夹中搜索g2o,找到后,右键属性,即可看到父文件夹,那就是安装目录了。