Installing and Running Point Cloud Library on Ubuntu

Standard

pcl
This article describes the steps to install the Point Cloud Library (PCL) in source and build it.

Ready to upgrade to Ubuntu 16.04 LTS?  You might find my more recent article on how to build PCL to Ubuntu 16.04.  

If you are interested in porting PCL to Raspberry Pi 3 running Ubuntu MATE (16.04), checkout this post.

Install PCL

To install the latest PCL on Ubuntu, you will need to use git. If you don’t have git installed, you can install it by

sudo apt-get update
sudo apt-get install git

The first command updates the apt-get list of repositories. The second command installs git on your machine. If you have git installed, change directory to a place where you want to store the source code, then proceed to clone the PCL repository and create a symbolic link:

git clone https://github.com/PointCloudLibrary/pcl.git pcl-trunk
ln -s pcl-trunk pcl

Now change directory to pcl you will see the PCL source code. Before we proceed with building the PCL libraries, we need to first install some prerequisites.

Install Prerequisites

Compiling PCL require a host of prerequisites, including cmake, git and several other packages. Follow the instructions below to install the prerequisites:

sudo apt-get install g++
sudo apt-get install cmake cmake-gui
sudo apt-get install doxygen  
sudo apt-get install mpi-default-dev openmpi-bin openmpi-common  
sudo apt-get install libflann1 libflann-dev
sudo apt-get install libeigen3-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libvtk5.8-qt4 libvtk5.8 libvtk5-dev
sudo apt-get install libqhull*
sudo apt-get install libusb-dev
sudo apt-get install libgtest-dev
sudo apt-get install git-core freeglut3-dev pkg-config
sudo apt-get install build-essential libxmu-dev libxi-dev 
sudo apt-get install libusb-1.0-0-dev graphviz mono-complete
sudo apt-get install qt-sdk openjdk-7-jdk openjdk-7-jre

The last apt-get install command may generate a window like below:
MissingPhonon
Answer OK to continue, but you may want to follow the recommendation and install any missing components. For me, I needed a couple of missing components to enable full operation of Phonon:

sudo apt-get install phonon-backend-gstreamer
sudo apt-get install phonon-backend-vlc

Install Kinect Support

To install OpenNI, do:

mkdir ~/kinect
cd ~/kinect
git clone https://github.com/OpenNI/OpenNI.git

And change the branch to unstable:

cd OpenNI
git checkout unstable

Run these lines to install OpenNI:

cd Platform/Linux/CreateRedist/
chmod +x RedistMaker
./RedistMaker
cd ../Redist/OpenNI-Bin-Dev-Linux-x64-v1.5.8.5
sudo ./install.sh

Now download another repository to the kinect folder:

cd ~/kinect/
git clone https://github.com/ph4m/SensorKinect.git

And change the branch to unstable

cd SensorKinect
git checkout unstable

And run these lines to install SensorKinect:

cd Platform/Linux/CreateRedist/
chmod +x RedistMaker
./RedistMaker
cd ../Redist/Sensor-Bin-Linux-x64-v5.1.2.1/
chmod +x install.sh
sudo ./install.sh

Note that the command line ./RedistMaker will compile several source files. If there was any error, you will not get a ../Redist folder, and therefore, you won’t be able to go to the next step. Fix the build error first and then rerun ./RedistMaker.

Compile and Install PCL

PCL is compiled using the cmake or cmake-gui utility. Change directory to the PCL source directory and enter the following commands:

mkdir release
cd release
cmake -DCMAKE_BUILD_TYPE=None -DBUILD_GPU=ON -DBUILD_apps=ON -DBUILD_examples=ON ..
make

(Note: For some reason the use of -DCMAKE_BUILD_TYPE=Release will lead to assembler error, but -DCMAKE_BUILD_TYPE=None will build just fine.)

Finally, to install PCL, enter the command:

sudo make install

The library files are installed at /usr/local/lib, and the header files are installed at /usr/local/include/pcl-1.7 (or whatever the version is). It might be a good idea to create a symbolic link referencing the latest version, this way your application does not have to change when the PCL is upgraded to the next version.

Further Reading

(The above article is solely the expressed opinion of the author and does not necessarily reflect the position of his current and past employers)