1.环境说明
编译环境是 Docker 的 Ubuntu 镜像所运行的容器实例,版本是"DockerVersion": "24.0.7"
。运行好容器后,第一部还是要配置好镜像源(或网络代理),然后更新软件仓库。
2.安装编译工具和依赖
创建安装脚本:
1
| touch install_build_pcl.sh
|
把下面内容添加到脚本中:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| #!/bin/bash
echo "更新系统并安装依赖项..." apt update apt upgrade -y
apt install -y build-essential cmake git pkg-config clang clangd wget unzip
apt install -y \ libusb-1.0-0-dev \ libusb-dev \ libudev-dev \ freeglut3-dev \ libxmu-dev \ libxi-dev \ libomp-dev
apt install -y \ libboost-all-dev \ libeigen3-dev \ libflann-dev \ libqhull-dev
apt install -y libvtk9-dev
apt install -y \ libglew-dev \ libglfw3-dev \ libpng-dev \ libjpeg-dev
apt install -y \ qtbase5-dev \ qttools5-dev-tools \ libqt5opengl5-dev
apt install -y \ libopenni-dev \ libopenni2-dev \ libpcap-dev
apt install -y language-pack-zh-hans
apt autoremove -y apt clean
echo "所有依赖项已安装!准备编译 PCL。"
|
将脚本更改为可执行权限:
1
| chmod +x install_build_pcl.sh
|
最好配置下.bashrc
,增加代理和中文字体配置。在.bashrc
中添加如下内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| export LANG=zh_CN.UTF-8 export LANGUAGE=zh_CN:zh export LC_ALL=zh_CN.UTF-8
proxy(){ export http_proxy="http://127.0.0.1:7890" export https_proxy="http://127.0.0.1:7890" echo "HTTP Proxy on" }
noproxy(){ unset http_proxy unset https_proxy echo "HTTP Proxy off" }
|
3.编译
3.1 拉取源码
可以通过git
拉取最新源码:
1
| git clone https://github.com/PointCloudLibrary/pcl.git
|
也可以直接下载指定版本源码并进行解压,比如1.14
版的:
1 2 3 4 5
| wget https://github.com/PointCloudLibrary/pcl/releases/download/pcl-1.14.1/source.zip
unzip source.zip -d .
|
3.2 开始编译
- 方式一:安装到默认目录
1 2 3 4 5 6 7 8 9 10 11
| cd pcl
mkdir build
cd build
cmake ..
make -j8
make install
|
- 方式二:安装到指定目录
比如要安装到/opt/pcl_1.14/
目录下:
开始编译:
1 2 3 4 5 6 7 8 9 10 11
| cd pcl
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/pcl_1.14
make -j8
make install
|
这种方式会把pcl
安装到/opt/pcl_1.14
下,pcl_1.14
下的文件结构是这样的:
1 2 3 4 5 6 7
| . ├── bin ├── include ├── lib └── share
5 directories, 0 files
|