有关Could not find a package configuration file provided by “CSparse” with any of the following names:问题的解决方案
在编译自己新建的有关g2o后端优化的程序时出现以下错误提示
CMake Error at CMakeLists.txt:10 (find_package):
By not providing "FindCSparse.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "CSparse", but
CMake did not find one.
Could not find a package configuration file provided by "CSparse" with any
of the following names:
CSparseConfig.cmake
csparse-config.cmake
Add the installation prefix of "CSparse" to CMAKE_PREFIX_PATH or set
"CSparse_DIR" to a directory containing one of the above files. If
"CSparse" provides a separate development package or SDK, be sure it has
been installed.
表示CSparse找不到,造成这一问题的根本在CMakelist.txt文件中的find_package(CSparse REQUIRED)这一句,无法定位CSparse导致的。
解决方案
1、解决的方法就是将十四讲书中第九讲原程序中自带的cmake文件夹复制到你刚刚建立的工程目录下,该文件夹中定义了编译运行过程中所用到的所有库的路径,使得该文件夹和新建立的工程中的CMakelist.txt文件保持在同一目录下。之后在新建立的工程中的CMakelist.txt中添加list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake),这一句用来引用cmake文件夹中赋予的路径,再次编译就通过了。
2、或者未安装CSparse,需要执行以下命令来安装CSparse。
sudo apt-get install libsuitesparse-dev