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)

11 thoughts on “Installing and Running Point Cloud Library on Ubuntu

  1. Raphael

    Thank you very much for the instructions !
    I managed to build and install everything, but with pcl-1.8.

    At the beginning, I had troubles to install the last dependencies (sudo apt-get install qt-sdk openjdk-7-jdk openjdk-7-jre) before noticing that “Pre-released updates” was unchecked in my Software Center. Checking it allowed me to install every dependencies correctly.

    After executing the “cmake …” command, I had to retry like 7/8 times the “make” command until it worked (I had the error : QtGui/QWidget not found, something like that). For that I changed a bit the CMakeLists.txt in the pcl source folder : added “include_directories(/usr/include/qt4)” just after the “cmake_minimum_required” line + I changed the version of qt used from 5 to 4 (at line “set(PCL_QT_VERSION 5 CACHE STRING “Which QT version to use”)”, replaced 5 by 4).

    After that, it still failed because it still tried to install things from qt5, so I went in the release folder, edited “CMakeCache.txt”, scrolled until I saw “PCL_QT_VERSION” and changed it to 4, then clicked generate and retried the make. It worked (after 1/2 – 3/4 hour of compilation).

    Also, as suggested in http://www.pointclouds.org/documentation/tutorials/compiling_pcl_posix.php,
    I added “-j2” after the two make commands for optimisation (not sure if that changed anything).

  2. Anna

    HI! Thanks for this tutorial. I try to follow but can’t get rid of the following error:

    ../../../../Include/XnStreamFormats.h:28:24: fatal error: XnPlatform.h: No such file or directory
    #include

    Can pls somebody help?

    Thanks so much in advance!

  3. yalan

    hi
    i followed this article but i have this error,could you plz help me?
    compilation terminated.
    make[2]: *** [apps/CMakeFiles/pcl_manual_registration.dir/include/pcl/apps/moc_manual_registration.cpp.o] Error 1
    make[1]: *** [apps/CMakeFiles/pcl_manual_registration.dir/all] Error 2
    make: *** [all] Error 2

  4. Savio Pereira

    Thanks a lot for this tutorial. I followed the tutorial to install PCL 1.8 on Ubuntu 16.04. I ran into the following error when I ran the cmake command :
    “By not providing “FindVTK.cmake” in CMAKE_MODULE_PATH this project has
    asked CMake to find a package configuration file provided by “VTK”, but
    CMake did not find one.

    Could not find a package configuration file provided by “VTK” (requested
    version 6.1) with any of the following names:

    VTKConfig.cmake
    vtk-config.cmake ”

    I was able to resolve it by pointing cmake to the installation location of VTK. To do this add the following argument to the cmake command:

    -DVTK_DIR=/usr/include/vtk-x.x

    where ‘x.x’ is the version of VTK Installed on your system.

  5. Srini

    Hi, I am following your instructions to install PCL, but I am getting the following error in the building process:

    [ 26%] Linking CXX shared library ../lib/libpcl_filters.so
    [ 26%] Built target pcl_filters
    Makefile:160: recipe for target ‘all’ failed
    make: *** [all] Error 2

  6. Kyunghee Kim

    Hi, Thank you very much for the tutorial. I installed PCL and OpenNI and SensorKinect on my laptop and and ran the openni grabber example from PCL at http://pointclouds.org/documentation/tutorials/openni_grabber.php#openni-grabber and I got this warning
    Warning: USB events thread – failed to set priority. This might cause loss of data…

    and the Kinect camera reading does not seem correct. Do you have any idea how I can resolve this issue? I’d really appreciate it. Thank you,

    • Alberto

      Until I know that is beacuse you are running the program as a simple user, If you run the program by terminal as a superuser, the warning doesn’t appear…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s