在编译ceres-solver的时候,报错找不到glog。完整的报错内容如下:
CMake Error at CMakeLists.txt:467 (message):
Can't find Google Log (glog). Please set either: glog_DIR (newer CMake
built versions of glog) or GLOG_INCLUDE_DIR & GLOG_LIBRARY or enable
MINIGLOG option to use minimal glog implementation.
也许,当看到找不到一个包的时候,我们的第一反应会是pip install一下。但是,无效。可能是因为pip是安装在虚拟环境内了吧,cmake并不能找到。而根据报错信息,可以看出,可选的解决方案有:
- set glog_DIR (newer CMake built versions of glog)
- set GLOG_INCLUDE_DIR & GLOG_LIBRARY
- enable MINIGLOG option to use minimal glog implementation
于是,我通过locate glog
命令,查找到了系统上的glog相关信息,如下图所示:
从前四行输出可以看到,原来我们在clone ceres源码下来的时候,就已经顺便把miniglog给克隆下来了。因此,第三个解决方案也许会是最简单的。我们打开该项目的CMakeLists.txt文件,找到报错的位置(我这里是第467行),然后,在前面加上set(MINIGLOG 1)
(也就是设置MINIGLOG这个变量值为1,这样就可以走if这个分支,就会自动编译miniglog了),如下图所示:
然后保存退出,再次进行cmake,该问题成功解决。