ubuntu 16.04 opencv+pcl+vtk环境部署

参考文档

https://www.jianshu.com/p/f646448da265
http://www.mamicode.com/info-detail-2580502.html

一.opencv3.4.1安装

1.安装依赖

sudo apt install cmake -y
sudo apt install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev -y 

2.解压缩安装

unzip opencv-3.4.1zip
cd opencv-3.4.1
mkdir build
cd build
cmake -D WITH_CUDA=OFF ..
make -j 8
sudo make install 

3.设置环境变量

sudo su -
echo "/usr/local/lib" >/etc/ld.so.conf.d/opencv.conf 
ldconfig

echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig" >> /etc/bash.bashrc  
echo "export PKG_CONFIG_PATH" >> /etc/bash.bashrc
source /etc/bash.bashrc

二.pcl1.8安装

1.安装依赖

sudo apt install libusb-1.0-0-dev libusb-dev libudev-dev  -y
sudo apt install mpi-default-dev openmpi-bin openmpi-common -y   
sudo apt install libflann1.8 libflann-dev  -y
sudo apt install libeigen3-dev  -y
sudo apt install libboost-all-dev -y 
sudo apt install libvtk5.10-qt4 libvtk5.10 libvtk5-dev  -y
sudo apt install libqhull* libgtest-dev  -y
sudo apt install freeglut3-dev pkg-config  -y
sudo apt install libxmu-dev libxi-dev   -y

2.解压安装

tar zxvf pcl-1.8.1.tar.gz
cd pcl-pcl-1.8.1
mkdir build
cd build
cmake ..
make -j 8
sudo make install

三.vtk安装
1.解压安装

tar zxvf VTK-7.1.1.tar.gz 
cd VTK-7.1.1/
mkdir build
cd build
cmake ..
make -j 8
sudo make install 

如上安装pcl或者vtk时可能报错如下,处理方案
报错

make[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/libGL.so', needed by 'lib/libvtkglew-7.1.so.1'.  Stop.
CMakeFiles/Makefile2:2675: recipe for target 'ThirdParty/glew/vtkglew/CMakeFiles/vtkglew.dir/all' failed
make[1]: *** [ThirdParty/glew/vtkglew/CMakeFiles/vtkglew.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

排错

root@mec12:~# ls -lh /usr/lib/x86_64-linux-gnu/libGL.so
lrwxrwxrwx 1 root root 13 Jun 15  2018 /usr/lib/x86_64-linux-gnu/libGL.so -> mesa/libGL.so
root@mec12:/usr/lib/x86_64-linux-gnu# cd /usr/lib/x86_64-linux-gnu/
root@mec12:/usr/lib/x86_64-linux-gnu# rm libGL.so
root@mec12:/usr/lib/x86_64-linux-gnu# ln -s libGL.so.1 libGL.so