cmake报错CMake Error at CMakeLists.txt: Can‘t find Google Log (glog). Please set either ... 的解决方法

  在编译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并不能找到。而根据报错信息,可以看出,可选的解决方案有:

  1. set glog_DIR (newer CMake built versions of glog)
  2. set GLOG_INCLUDE_DIR & GLOG_LIBRARY
  3. 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,该问题成功解决。

猜你喜欢

转载自blog.csdn.net/weixin_44120025/article/details/128053713