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:
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)
CMake Error at /usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find FLANN (missing: FLANN_LIBRARIES FLANN_INCLUDE_DIR) (Required
is at least version “1.7.0”)
Call Stack (most recent call first):
/usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
cmake/Modules/FindFLANN.cmake:111 (find_package_handle_standard_args)
CMakeLists.txt:290 (find_package)
I am getting error while installing OpenNI. The errors are following.
*********************************
* PrimeSense OpenNI Redist *
* 2017-08-21 20:12:47 *
*********************************
Target: Linux-x64
Version: 1.5.8.5
Num of compile jobs: 8
* Building OpenNI…
../../../../../Samples/NiViewer/Device.cpp: In function ‘XnStatus openDeviceFromXmlWithChoice(const char*, xn::EnumerationErrors&)’:
../../../../../Samples/NiViewer/Device.cpp:251:22: warning: ignoring return value of ‘int scanf(const char*, …)’, declared with attribute warn_unused_result [-Wunused-result]
scanf(“%d”, &chosen);
^
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar: error reading zip file
Exception in thread “main” java.lang.NoClassDefFoundError: sun/net/util/URLUtil
at sun.misc.URLClassPath.getLoader(URLClassPath.java:352)
at sun.misc.URLClassPath.getResource(URLClassPath.java:225)
at java.net.URLClassLoader$1.run(URLClassLoader.java:351)
at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:312)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
make[1]: *** [../../../Bin/x64-Release/org.openni.jar] Error 1
make: *** [Wrappers/OpenNI.java] Error 2
make: *** Waiting for unfinished jobs….
failed to execute: make -j8 -C /home/user/kinect/OpenNI/Platform/Linux/CreateRedist/../Build > /home/user/kinect/OpenNI/Platform/Linux/CreateRedist/Output/BuildOpenNI.txt
Building Failed!
Will you help me regarding this issue.
Thanks
It looks this is the root error:
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar: error reading zip file.
I’d start by checking if the file the build is looking for is there.
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).
-j2 just make use of parallel threads, good if you have multi-core CPU.
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!
Are you running Ubuntu 16.04? The error is related to OpenNI or SensorKinect step. please list out the steps in detail..
HI!
Yes running on Ubuntu 16.04
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
@YALAN: Did yo try follow this? This page is for Ubuntu 14.04LTS. For 16.04 did you try follow this:
https://larrylisky.com/2016/11/03/point-cloud-library-on-ubuntu-16-04-lts/
-Larry
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.
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
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,
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…