1、Ceres是一个cmak工程,首先要安装他的依赖项,使用apt-get安装。
sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3.1.2 libgflags-dev libgoogle-glog-dev libgtest-dev
2、如果安装时找不到 cxsparse 或者其他的lib,需要添加下面的源。
(1)先使用如下命令打开source.list
sudo gedit /etc/apt/sources.list
(2)然后讲下面的源粘贴到source.list的最上方
deb http://cz.archive.ubuntu.com/ubuntu trusty main universe
(3)更新源
sudo apt-get update
(4)在输入1中的命令安装依赖项。
3.Ceres库是来自谷歌的非线性优化库,建议去github上下载
git clone https://ceres-solver.googlesource.com/ceres-solver
下载并解压后,切换到Ceres库所在目录,按如下步骤输入命令编译和安装。这需要花费一段时间。
mkdir build
cd build
cmake ..
make
4、编译完成后安装。
sudo make install
5、Ceres库的头文件安装在"/usr/local/include/ceres/"目录下,库文件安装在"/usr/local/lib/"目录下。
安装完成后查看是否有对应的文件,如果有则说明安装成功。
PCL库安装步骤:
如果是ubuntu14,则可以使用以下命令
sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl
sudo apt-get update
sudo apt-get install libpcl-all
但如果是ubuntu16及以上版本,则使用以下命令
sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl
sudo apt-get update
sudo apt-get install libpcl-dev
注意:如果第三步install的是libpcl-all,会提示无法定位软件包libpcl-all;
update可能会出错,提示:PPA仓库没有Release文件,这个问题可以忽略;
如果install失败,可以再执行一次update,然后install;
小bug:
在学习《视觉SLAM十四讲》的时候,安装Ceres的依赖项,在安装libcxsparse3.1.2时,出先错误。
即,当
$sudo apt-get install libcxsparse3.1.2 时,出先错误如下:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libcxsparse3.1.2
E: Couldn't find any package by glob 'libcxsparse3.1.2'
E: Couldn't find any package by regex 'libcxsparse3.1.2'
一开摸不着头脑,查了几遍确定没有输入错误,然后就去“科学搜索”,发现了下面的帖子:
https://askubuntu.com/questions/378558/unable-to-locate-package-while-trying-to-install-packages-with-apt
按照里面的方法一步一步去找:
First, check if the package actually exists:
- Go to packages.ubuntu.com with a web browser.
- Scroll down to "Search package directories"
-
Enter the package which you're trying to install into the "Keyword" field.
Enable "Only show exact matches:"
Change the "Distribution" to which version of Ubuntu you're using.
之后搞明白,其实安装包是存在的,不过libcxsparse3.1.2对应的ubuntu14.04 LTS(trusty),而我用的是ubuntu16.04 LTS(xenial),对应的版本是libcxsparse3.1.4,所以安装之就可以了。