安装 cartographer踩坑 (ubuntu 16.04 + kinetic)

主要参考博文:

http://www.cnblogs.com/lvchaoshun/p/9824528.html

这篇博文采用的是分别安装的方法。

  1. ceres-solver
  2. proto3
  3. cartographer
  4. cartographer_ros。

最后面的 cartographer_ros包的安装就是源码拷贝到工作空间.

可以新建一个工作空间也可以用原来的。然后直接进行编译。

遇到的问题:

一 protobuf 版本混乱问题

按着教程的安装方式安装proto3,我们需要把ubuntu里原来的proto的版本更换到3。
对应的就是教程的3.6.0.
到ghithub上下载

https://github.com/google/protobuf/releases

下载 3.6.0 的all版本。

安装的时候尤其注意安装路径。

如果不设置安装路径, 也就是执行这句。

$ ./configure

一般情况下,默认会安装到/usr/include文件下,这样就会与ROS自带的proto2发生版本冲突。

因此我们需要找个位置

而我们需要指定安装到,/usr/local/include文件下.

安装完成会有一个goole文件在/usr/local/include 下。

这个和google文件夹下就是protobuf

正确的安装方法如下:

$ tar zxvf protobuf-all-3.6.0.tar.gz
$ cd protobuf-3.6.0/
$ ./configure -prefix=/usr/local/        
# (安装路径,一般情况下,默认会安装到/usr/include 文件下,我们需要指定安装到,/usr/local/include文件下,安装完成会有一个goole文件在/usr/local/include 下)
$ make
$ make check
$ make install
$ protoc -version 

二 共享库路径问题

刚开始按着别的教程安的protobuf3.6.0

但是在查版本型号的时候遇到了找不到共享库的问题。

$ protoc --version

error:

error while loading shared libraries: libprotobuf.so.8: cannot open shared object file: No such file or directory

解决办法:

原因一般有两个

一个是操作系统里确实没有包含该共享库(lib.so.文件)或者共享库版本不对.

遇到这种情况那就去网上下载并安装上即可.

另外一个原因就是已经安装了该共享库

但执行需要调用该共享库的程序的时候程序按照默认共享库路径找不到该共享库文件。

顺着教程的目录找一找,共享库文件,设置一下路径。

https://www.cnblogs.com/Anker/p/3209876.html
https://blog.csdn.net/sahusoft/article/details/7388617

三 手欠!编译完改文件夹名

在ceres-solver proto3 cartographer都安装完成。cartographer_ros编译通过之后。

我手欠地把存放 ceres-solver cartographer 源码的文件夹改名了!

所以菜鸡处处是问题。

error:
$ /usr/local/include/cartographer/io/points_processor_pipeline_builder.h:23:42: fatal error: absl/container/flat_hash_map.h: 没有那个文件或目录

然后意识到问题,重新编译ceres-solver和cartographer试了一下。报错如下。

CMake Error: The current CMakeCache.txt directory /home/vistar/desktop/catkin_ws/build/CMakeCache.txt is different than the directory /home/vistar/桌面/catkin_ws/build where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt

解决办法:

将…/build/CMakeCache.txt删掉,重新编译将…/build/CMakeCache.txt删掉,重新编译

https://blog.csdn.net/maizousidemao/article/details/88895990