Installing Point Cloud Library (PCL) on Windows using Visual Studio 2013

I’m at a point in my research where I need to register points I’ve segmented from a series of ultrasound images in a single 3D reconstruction of a target area. Having very little experience with 3D reconstruction, I went on a search for possible libraries to use and stumbled upon the Point Cloud Library. It looked very promising so I decided to use it. The problem was, the installers were built on an older version of Visual Studio. Therefore, I had to build and install my own version of PCL. It turns out it was much harder than my previous experience building a custom library (OpenCV + Python) as it has many dependencies that need to also be custom built with the same Visual Studio version. It took me several days, as the instructions on the PCL website were not very detailed. So, for future reference and for those who need to do the same, this is a description of the build and installation process for PCL on Windows using Visual Studio 2013.

Building the PCL Library

The PCL library has several dependencies that need to be built or installed beforehand with the same compiler used to build the PCL library. In this post, the build procedures for each dependency as well as the PCL library itself will be described. The steps taken to successfully build and install the PCL library and its dependencies include:

  1. Build and Install Boost 1.60 Using b2 Compiler
  2. Build and Install Flann 1.8.4 Using Cmake and Visual Studio
  3. Build and Install Eigen 3.2.7 Using Cmake and Visual Studio
  4. Build and Install Qhull 2015.2 Using Cmake and Visual Studio
  5. Build and Install VTK 6.3.0 with Qt Support Using Cmake and Visual Studio

After each of the above dependencies have been built and installed the PCL library can be built.

  1. Build and Install PCL Using Cmake and Visual Studio
  2. Test PCL Library in Visual Studio Using Example Program

The PCL build used in my research and this tutorial is the 64-bit version. Therefore, the PCL libraries and all of its dependencies will be built for the 64-bit machine. All of the libraries that will be built above, except for Boost, are built using CMake and Visual Studio 2013. If you do not have these installed yet, you can download them here:

Building and Installing Boost 1.6.0 Using b2 Compiler

The Boost library is a free peer-reviewed portable C++ source library. For PCL on Windows, the Boost library needs to be built with Microsoft MPI support. Therefore, two libraries need to be downloaded for this process.

Download

Build Procedure

  • Install Microsoft MPI Library – One of the requirements for PCL is that Boost be built with Microsoft MPI support. Therefore, before building the Boost library, Microsoft MPI needs to be installed. Download the newest version of Microsoft MPI (Version 7) using the above link into their default installation location (C:\Program Files\MPI for the .exe file and  C:\Program Files (x86)\Microsoft SDKs\MPI for the .msi file). Once MPI has been install, we begin the Boost build process.
  • Prepare Boost 1.60 for  Build – Download Boost 1.60 in the link provided above and extract the zip file to an easy to reach destination (For me, it was C:\boost_1_60_0). Unlike the other dependencies and libraries that will be built in this tutorial, Boost comes with its own simplified build procedure called b2. Therefore, CMake and Visual Studio are not used to build and install the library. Before using the b2 command a configuration file needs to edited to include the MPI library inside the Boost build. Open mpi.jam located at C:\boost_1_60_0\tools\build\src\tools\mpi.jam and revise the following lines of code:
local microsoft_mpi_sdk_path = "C:\\Program Files (x86)\\Microsoft SDKs\\MPI" ;
local microsoft_mpi_path = "C:\\Program Files\\Microsoft MPI" ;
if [ GLOB $(microsoft_mpi_sdk_path)\\Include : mpi.h ]
ECHO "Found Microsoft Compute Cluster Pack: $(microsoft_mpi_sdk_path)" ;
options = <include>$(microsoft_mpi_sdk_path)/Include
<address-model>64:	<library-path>$(microsoft_mpi_sdk_path)/Lib/x64
	<library-path>$(microsoft_mpi_sdk_path)/Lib/x86
.mpirun = "\"$(microsoft_mpi_path)\\Bin\\mpiexec.exe"\" ;
ECHO "Did not find Microsoft Compute Cluster Pack in $(microsoft_mpi_sdk_path)."
  • Start Build Process using Bootstrap – Open either the VS2013 x64 Native Tools Command Prompt or the VS2013 x64 Cross Tools Command Prompt using shortcuts located in the Visual Studio install directory (C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts) as Administrator. Change the directory to the Boost directory and run bootstrap.bat from the command prompt.
  • Edit Build Configuration – Once bootstrap has finished its build initiation process, files used in the Boost build and installation process will be produced. To include the MPI library in the build, open the file  C:\boost_1_60_0\project-config.jam and add the following line of code:
using mpi ;
  • Build and Install Boost Library – The Boost library can be built using the commands in the code snippet below. These commands build the 64-bit version of Boost (address-model=64) using Visual Studio 2013 (toolset=msvc-12.0), stores the result of the build in a predefined location (–build-dir=build\x64) and installs the necessary Boost libraries and include files in a predefined installation directory (install –prefix=”C:\Program Files\Boost”) with 8 parallel computations of the CPU (-j8)
b2.exe toolset=msvc-12.0 address-model=64 --build-dir=build\x64 install --prefix="C:\Program Files\Boost" -j8

The result of the build and installation process will look something like this:

boost

Building and Installing Flann 1.8.4 Using Cmake and VS2013

FLANN is a library that contains a collection of algorithms to perform fast approximate nearest neighbor searches in high dimensional spaces. It is a required dependency of the PCL library. Unlike the Boost library described previously, Flann is built using CMake and Visual Studio. The Flann library can be downloaded from the developer’s site using the link below.

Download

Build Procedure

  • Set CMake Source and Build Folders – Extract the zip file to an easy to open directory (C:\flann-1.8.4-src). Open the CMake GUI, and set the source and build folders of the build as follows.
    • Source Directory – C:\flann-1.8.4-src
    • Build Directory – C:\flann-1.8.4-src\build
  • Configure CMake Build – Press the Configure button in the CMake GUI to produce the configuration options. If prompted, make sure that the compiler used is set to Visual Studio 2013. Once the configuration options have been produced, set the configuration options below to the correct value:
    • BUILD_C_BINDINGS – checked
    • BUILD_MATLAB_BINDINGS – unchecked
    • BUILD_PYTHON_BINDINGS – unchecked
    • CMAKE_CONFIGURATION_TYPES – Debug;Release
    • CMAKE_INSTALL_PREFIX – C:\Program Files\Flann
  • Add Debug Configuration Settings –  To differentiate between the Debug and Release files, a postfix is added to the Debug files. This can be done by adding a CMake configuration entry. Press the Add Entry button in the CMake GUI and use the following settings for the new entry:
    • Name: CMAKE_DEBUG_POSTFIX
    • Type: STRING
    • Value: -gd
  • Generate Build Files – Once all the configurations have been set up, the build files can be produced by clicking the Generate button.
  • Edit Build File for 64-bit Build – Several lines of code need to be added to the Flann source code to allow for the 64-bit library build. Open serialization.h at C:\flann-1.8.4-src\src\cpp\flann\util and insert the following code in line 92 of the file:
#ifdef _MSC_VER
BASIC_TYPE_SERIALIZER( unsigned __int64 );
#endif
  • Build Library Files – Visual Studio is used to build the library files. To allow installation after the build, open Visual Studio under Administrator control. Open the build solution called flann.sln at C:\flann-1.8.4-src\build. For each build configuration, perform the following procedures to build the Flann library.
    1. Set the configuration of the solution to either Debug or Release
    2. Right-click the ALL_BUILD project in the Solution Explorer
    3. Select Build to build the Flann library under the selected configuration
  • Install Library Files – After the library has been successfully built, the necessary library files that are used can be installed in a separate directory using the following procedure.
    1. Set the configuration of the solution to either Debug or Release
    2. Right-click the INSTALL project in the Solution Explorer
    3. Select Build to install the Flann library in the location predefined at the CMake configuration named CMAKE_INSTALL_PREFIX

Building and Installing Eigen 3.2.7 Using CMake and VS2013

Eigen is a template library for linear algebra which contains templates for matrices, vectors, numerical solvers, and related algorithms. Since it is a pure template library, Eigen does not need to be built. However, CMake and Visual Studio can be used to install Eigen to a predefined directory similar to the Flann library described previously. The Eigen library can be downloaded using the link provided below. For this build, I used the latest stable release which at the time was 3.2.7.

Download

Install Procedure

  • Set CMake Source and Build Folders – Extract the zip file to an easy to open directory (C:\eigen). Open the CMake GUI, and set the source and build folders of the build as follows.
    • Source Directory – C:\eigen
    • Build Directory – C:\eigen\build
  • Configure CMake Build – Press the Configure button in the CMake GUI to produce the configuration options. If prompted, make sure that the compiler used is set to Visual Studio 2013. Once the configuration options have been produced, set the configuration options below to the correct value:
    • CMAKE_INSTALL_PREFIX – C:\Program Files\Eigen
  • Generate Build Files – Generate the build files by clicking on the Generate button in the CMake GUI.
  • Install Library Files – The Eigen library does not need to be built, therefore it is installed directly using the following procedure.
    1. Open Visual Studio under Administrator control
    2. Open eigen.sln solution in the build directory defined above
    3. Set the configuration of the solution to either Debug or Release
    4. Right-click the INSTALL project in the Solution Explorer
    5. Select Build to install the Eigen library in the location predefined at the CMake configuration named CMAKE_INSTALL_PREFIX

Building and Installing QHull 2015.2 Using CMake and VS2013

Qhull is a C++ library that implements the Quickhull algorithm to compute convex hulls in 2-D, 3-D, 4-D, and higher dimensions. It is a dependency of the PCL library, hence it needs to be built and installed beforehand. I used the latest version of Qhull (2015.2) which can be downloaded in the link below.

Download

Build Procedure

  • Set CMake Source and Build Folders – Extract the zip file to an easy to open directory (C:\qhull-2015.2). Open the CMake GUI, and set the source and build folders of the build as follows.
    • Source Directory – C:\qhull-2015.2
    • Build Directory – C:\qhull-2015.2\build
  • Configure CMake Build – Press the Configure button in the CMake GUI to produce the configuration options. If prompted, make sure that the compiler used is set to Visual Studio 2013. Once the configuration options have been produced, set the configuration options below to the correct value:
    • CMAKE_CONFIGURATION_TYPES – Debug;Release
    • CMAKE_INSTALL_PREFIX – C:\Program Files\Qhull
  • Add Debug Configuration Settings –  To differentiate between the Debug and Release files, a postfix is added to the Debug files. This can be done by adding a CMake configuration entry. Press the Add Entry button in the CMake GUI and use the following settings for the new entry:
    • Name: CMAKE_DEBUG_POSTFIX
    • Type: STRING
    • Value: _d
  • Generate Build Files – Once all the configurations have been set up, the build files can be produced by clicking the Generate button.
  • Build Library Files – Visual Studio is used to build the library files. To allow installation after the build, open Visual Studio under Administrator control. Open the build solution called qhull.sln at C:\qhull-2015.2\build. For each build configuration, perform the following procedures to build the Qhull library.
    1. Set the configuration of the solution to either Debug or Release
    2. Right-click the ALL_BUILD project in the Solution Explorer
    3. Select Build to build the Qhull library under the selected configuration
  • Install Library Files – After the library has been successfully built, the necessary library files that are used can be installed in a separate directory using the following procedure.
    1. Set the configuration of the solution to either Debug or Release
    2. Right-click the INSTALL project in the Solution Explorer
    3. Select Build to install the Qhull library in the location predefined at the CMake configuration named CMAKE_INSTALL_PREFIX

Building and Installing VTK 6.3.0 with Qt Support Using CMake and VS2013

VTK, or The Visualization Toolkit, is an open-source library for 3D computer graphics, image processing, and visualization. It is a dependency of the PCL library, hence it needs to be built and installed beforehand. To support GUI development using Qt, the VTK library can be built with Qt integrated into the library. For this tutorial, I build the latest VTK library release (6.3.0) with the latest Qt release integrated into the library. Therefore, Qt is installed before the VTK build.

Download

Install Qt 5.5.1

  • Qt can be installed using the installer provided by Qt. To allow integration into VTK, the Qt library installed needs to be compiled using the same compiler as the VTK library that is to be built. Therefore, the Qt 5.5.1 64-bit built with VS2013 is used. This version can be installed using the offline installer here. Follow the instructions in the installer and install Qt in the default location selected by the installer (My Qt installation is located at C:\Qt).

Build Procedure

  • Acquire VTK Source – Download VTK Source in the link above and unzip the zip file to an easy to reach directory (C:\VTK-6.3.0)
  • Delete Unsupported Source Folder – Since Qt 5.5, QtWebkit has been deprecated by the Qt library. Therefore, the VTK source code related with QtWebkit needs to be removed. Delete the QtWebkit folder at C:\VTK-6.3.0 \ GUISupport \ QtWebkit
  • Set CMake Source and Build Folders – Open the CMake GUI, and set the source and build folders of the build as follows.
    • Source Directory – C:\VTK-6.3.0
    • Build Directory – C:\VTK-6.3.0\build
  • Configure CMake Build – Press the Configure button in the CMake GUI to produce the configuration options. If prompted, make sure that the compiler used is set to Visual Studio 2013. Once the configuration options have been produced, set the configuration options below to the correct value. If some of the values cannot be seen in the configuration window, put a check in the Advanced checkbox near the top of the GUI.
    • VTK
      • VTK_Group_Qt – checked
      • VTK_INSTALL_QT_PLUGIN_DIR – $ {CMAKE_INSTALL_PREFIX} / $ {VTK_INSTALL_QT_DIR}
      • VTK_QT_VERSION – 5
    • BUILD
      • BUILD_SHAREED_LIBS – checked
      • BUILD_TESTING – unchecked
    • CMAKE
      • CMAKE_CONFIGURATION_TYPES – Debug;Release
      • CMAKE_CXX_MP_FLAG – checked
      • CMAKE_INSTALL_PREFIX – C:\Program Files\VTK
    • OPENGL
      • OPENGL_gl_LIBRARY – opengl
      • OPENGL_glu_LIBRARY – glu32
    • Ungrouped Entries
      • QT_QMAKE_EXECUTABLE – C:\Qt\bin\qmake.exe
      • Qt5_DIR – C:\Qt\lib\cmake\Qt5
      • Qt5Core_DIR – C:\Qt\lib\cmake\Qt5Core
      • Qt5Designer_DIR – C:\Qt\lib\cmake\Qt5Designer
      • Qt5Gui_DIR – C:\Qt\lib\cmake\Qt5Gui
      • Qt5OpenGL_DIR – C:\Qt\lib\cmake\Qt5OpenGL
      • Qt5Sql_DIR – C:\Qt\lib\cmake\Qt5Sql
      • Qt5UiPlugin_DIR – C:\Qt\lib\cmake\Qt5UiPlugin
      • Qt5Widgets_DIR – C:\Qt\lib\cmake\Qt5Widgets
      • Qt5Xml_DIR – C:\Qt\lib\cmake\Qt5Xml
      • VTK_INSTALL_QT_PLUGIN_DIR – $ {CMAKE_INSTALL_PREFIX} / $ {VTK_INSTALL_QT_DIR}
  • Add Debug Configuration Settings –  To differentiate between the Debug and Release files, a postfix is added to the Debug files. This can be done by adding a CMake configuration entry. Press the Add Entry button in the CMake GUI and use the following settings for the new entry:
    • Name: CMAKE_DEBUG_POSTFIX
    • Type: STRING
    • Value: -gd
  • Generate Build Files – Once all the configurations have been set up, the build files can be produced by clicking the Generate button.
  • Edit Build File for Debug and Release Configurations– Several lines of code need to be added to the VTK build file to accommodate for the installation of both the Debug and Release build. Open C:\VTK-6.3.0\build\GUISupport\Qt\PluginInstall.cmake in a text editor and insert the following code in line 5 of the file:
IF(BUILD_TYPE MATCHES Debug)
SET(VTK_INSTALL_QT_PLUGIN_FILE "QVTKWidgetPlugin-gd.dll")
ELSE()
SET(VTK_INSTALL_QT_PLUGIN_FILE "QVTKWidgetPlugin.dll")
ENDIF ()
  • Build Library Files – Visual Studio is used to build the library files. To allow installation after the build, open Visual Studio under Administrator control. Open the build solution called VTK.sln at C:\VTK-6.3.0\build. For each build configuration, perform the following procedures to build the VTK library.
    1. Set the configuration of the solution to either Debug or Release
    2. Right-click the ALL_BUILD project in the Solution Explorer
    3. Select Build to build the VTK library under the selected configuration
  • Install Library Files – After the library has been successfully built, the necessary library files that are used can be installed in a separate directory using the following procedure.
    1. Set the configuration of the solution to either Debug or Release
    2. Right-click the INSTALL project in the Solution Explorer
    3. Select Build to install the VTK library in the location predefined at the CMake configuration named CMAKE_INSTALL_PREFIX

Building and Installing PCL Using CMake and VS2013

Only after all of the dependencies have been properly built and installed for VS2013 can the PCL library be built and installed. I used the latest stable release of the PCL library (PCL 1.7.2) which can be downloaded using the link provided below. The build process, using CMake and Visual Studio is similar to the build process in the previously described dependencies.

Download

Build Process

  • Acquire PCL Source – Download the latest PCL library source in the GitHub page using the link above and unzip the zip file to an easy to reach directory (C:\PCL-1.7.2)
  • Set CMake Source and Build Folders – Open the CMake GUI, and set the source and build folders of the build as follows.
    • Source Directory – C:\PCL-1.7.2
    • Build Directory – C:\PCL-1.7.2\build
  • Configure CMake Build – Press the Configure button in the CMake GUI to produce the configuration options. If prompted, make sure that the compiler used is set to Visual Studio 2013. Once the configuration options have been produced, set the configuration options below to the correct value. If some of the values cannot be seen in the configuration window, put a check in the Advanced checkbox near the top of the GUI. An error will occur during configuration if one of the values below (especially those with links) are not filled. Sometimes, some of the fields listed below are not available after the first press of the configuration button. Fill in the available fields, then click configure again, and some previously unavailable fields will now be available. Repeat the process untill all of the configurations below are filled.
    • WITH
      • WITH_DOCS – unchecked
      • WITH_FZAPI – unchecked
      • WITH_LIBUSB – unchecked
      • WITH_OPENNI – unchecked
      • WITH_OPENNI2 – unchecked
      • WITH_PCAP – unchecked
      • WITH_PNG – unchecked
      • WITH_PXCAPI – unchecked
      • WITH_QHULL – checked
      • WITH_QT – unchecked
      • WITH_VTKchecked
    • BUILD
      • BUILD_OPENNI – unchecked
      • BUILD_OPENNI2 – unchecked
      • BUILD_all_in_one_installer – unchecked
      • BUILD_apps – unchecked
      • BUILD_common – checked
      • BUILD_example – unchecked
      • BUILD_featureschecked
      • BUILD_filterschecked
      • BUILD_geometrychecked
      • BUILD_global_tests – unchecked
      • BUILD_iochecked
      • BUILD_kdtreechecked
      • BUILD_keypointschecked
      • BUILD_outofcorechecked
      • BUILD_peoplechecked
      • BUILD_recognitionchecked
      • BUILD_registrationchecked
      • BUILD_sample_consensuschecked
      • BUILD_searchchecked
      • BUILD_segmentationchecked
      • BUILD_surfacechecked
      • BUILD_surface_on_nurbschecked
      • BUILD_toolschecked
      • BUILD_trackingchecked
      • BUILD_visualizationchecked
    • CMAKE
      • CMAKE_CONFIGURATION_TYPES – Debug;Release
      • CMAKE_INSTALL_PREFIX – C:\Program Files\PCL
    • Boost
      • Boost_DATE_TIME_LIBRARY_DEBUG – C:\Program Files\Boost\lib\libboost_date_time-vc120-mt-gd-1_60.lib
      • Boost_DATE_TIME_LIBRARY_RELEASE – C:\Program Files\Boost\lib\libboost_date_time-vc120-mt-1_60.lib
      • Boost_FILESYSTEM_LIBRARY_DEBUG – C:\Program Files\Boost\lib\libboost_filesystem-vc120-mt-gd-1_60.lib
      • Boost_FILESYSTEM_LIBRARY_RELEASE – C:\Program Files\Boost\lib\libboost_filesystem-vc120-mt-1_60.lib
      • Boost_INCLUDE_DIR – C:\Program Files\Boost\include\boost-1_60
      • Boost_IOSTREAMS_LIBRARY_DEBUG – C:\Program Files\Boost\lib\libboost_iostreams-vc120-mt-gd-1_60.lib
      • Boost_IOSTREAMS_LIBRARY_RELEASE – C:\Program Files\Boost\lib\libboost_iostreams-vc120-mt-1_60.lib
      • Boost_MPI_LIBRARY_DEBUG – C:\Program Files\Boost\lib\libboost_mpi-vc120-mt-gd-1_60.lib
      • Boost_MPI_LIBRARY_RELEASE – C:\Program Files\Boost\lib\libboost_mpi-vc120-mt-1_60.lib
      • Boost_SERIALIZATION_LIBRARY_DEBUG – C:\Program Files\Boost\lib\libboost_serialization-vc120-mt-gd-1_60.lib
      • Boost_SERIALIZATION_LIBRARY_RELEASE – C:\Program Files\Boost\lib\libboost_serialization-vc120-mt-1_60.lib
      • Boost_SYSTEM_LIBRARY_DEBUG – C:\Program Files\Boost\lib\libboost_system-vc120-mt-gd-1_60.lib
      • Boost_SYSTEM_LIBRARY_RELEASE – C:\Program Files\Boost\lib\libboost_system-vc120-mt-1_60.lib
      • Boost_THREAD_LIBRARY_DEBUG – C:\Program Files\Boost\lib\libboost_thread-vc120-mt-gd-1_60.lib
      • Boost_THREAD_LIBRARY_RELEASE – C:\Program Files\Boost\lib\libboost_thread-vc120-mt-1_60.lib
      • Boost_LIBRARY_DIR_DEBUG – C:\Program Files\Boost\lib
      • Boost_LIBRARY_DIR_RELEASE – C:\Program Files\Boost\lib
    • FLANN
      • FLANN_INCLUDE_DIR – C:\Program Files\flann\include
      • FLANN_LIBRARY – C:\Program Files\flann\lib\flann_cpp_s.lib
      • FLANN_LIBRARY_DEBUG – C:\Program Files\flann\lib\flann_cpp_s-gd.lib
    • QHULL
      • QHULL_INCLUDE_LIBRARY – C:\Program Files\qhull\include
      • QHULL_LIBRARY – C:\Program Files\qhull\lib\qhullstatic.lib
      • QHULL_LIBRARY_DEBUG – C:\Program Files\qhull\lib\qhullstatic_d.lib
    • Ungrouped Entries
      • EIGEN_INCLUDE_DIR – C:\Program Files\Eigen\include\eigen3
      • VTK_DIR – C:\Program Files\VTK\lib\cmake\vtk-6.3

pclconfigure

  • Generate Build Files – Once all the configurations have been set up, the build files can be produced by clicking the Generate button.
  • Edit Build File for Debug and Release Configurations– Several lines of code need to be added to the PCL build file to accommodate for the installation of 3rdParty dependencies in the PCL installation directory. Basically, include and library files for the dependencies listed above are included in the PCL installation directory to ease the setup of include and linker files during development of PCL based applications. To do this, open C:\PCL-1.7.2\build\cmake_install.cmake in a text editor and insert the following code in line 46 of the file:
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/3rdParty/Boost" TYPE DIRECTORY FILES "C:/Program Files/Boost/" REGEX "/[^/]*\\/uninstall\\.exe$" EXCLUDE)
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/3rdParty/VTK" TYPE DIRECTORY FILES "C:/Program Files/VTK/" REGEX "/[^/]*\\/uninstall\\.exe$" EXCLUDE)
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/3rdParty/Eigen" TYPE DIRECTORY FILES "C:/Program Files/Eigen/" REGEX "/[^/]*\\/uninstall\\.exe$" EXCLUDE)
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/3rdParty/Flann" TYPE DIRECTORY FILES "C:/Program Files/flann/" REGEX "/[^/]*\\/uninstall\\.exe$" EXCLUDE)
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/3rdParty/Qhull" TYPE DIRECTORY FILES "C:/Program Files/qhull/" REGEX "/[^/]*\\/uninstall\\.exe$" EXCLUDE)
  • Build Library Files – Visual Studio is used to build the library files. To allow installation after the build, open Visual Studio under Administrator control. Open the build solution called PCL.sln at C:\PCL-1.7.2\build. For each build configuration, perform the following procedures to build the PCL library.
    1. Set the configuration of the solution to either Debug or Release
    2. Right-click the ALL_BUILD project in the Solution Explorer
    3. Select Build to build the PCL library under the selected configuration
  • Install Library Files – After the library has been successfully built, the necessary library files that are used can be installed in a separate directory using the following procedure.
    1. Set the configuration of the solution to either Debug or Release
    2. Right-click the INSTALL project in the Solution Explorer
    3. Select Build to install the PCL library in the location predefined at the CMake configuration named CMAKE_INSTALL_PREFIX
  • Installed library files will have a postfix of _debug for the Debug configuration and a postfix of _release for the Release configuration.
  • In order for the PCL library to function properly, add the following Environment Variables to your system.
    • New Environment Variable PCL_ROOT set to C:\Program Files\PCL
    • Add the following links to the Path variable:
      • %PCL_ROOT%\bin
      • %PCL_ROOT%\3rdParty\Flann\bin
      • %PCL_ROOT%\3rdParty\VTK\bin

Testing the PCL Library

Once the PCL library has been built, we can test it with a sample program to see whether the library has been installed correctly. The program shown below produces a text file called test_pcd.pcd that consists of a few random points in the point cloud format. If the PCL library has been installed and configured correctly, the text file should be produced and saved in the project folder.

#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

int main(int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ> cloud;

// Fill in the cloud data
cloud.width = 5;
cloud.height = 1;
cloud.is_dense = false;
cloud.points.resize(cloud.width * cloud.height);

for (size_t i = 0; i < cloud.points.size(); ++i)
{
cloud.points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
cloud.points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
cloud.points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
}

pcl::io::savePCDFileASCII("test_pcd.pcd", cloud);
std::cerr << "Saved " << cloud.points.size() << " data points to test_pcd.pcd." << std::endl;

for (size_t i = 0; i < cloud.points.size(); ++i)
std::cerr << " " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;

return (0);
}

To run the above program in Visual Studio, the project needs to be configured to run the PCL library. The configuration for a basic PCL project consists of including/linking both the PCL library and its dependencies. As with any Visual Studio projects, the configurations can be accessed by right-clicking the project in the solution explorer and selecting Properties. Under the Configuration Properties > C/C++ > General > Additional Include Directories, the following include directories are added (based on the install directories I used above):

Qt - C:\Qt\Qt5.5.1\5.5\msvc2013_64\include
PCL - C:\Program Files\PCL\include\pcl-1.7
PCL 3rd Party - C:\Program Files\PCL\3rdParty
Boost - C:\Program Files\PCL\3rdParty\Boost\include\boost-1_60
Eigen - C:\Program Files\PCL\3rdParty\Eigen\include\eigen3
Flann - C:\Program Files\PCL\3rdParty\Flann\include
Qhull - C:\Program Files\PCL\3rdParty\Qhull\include
VTK - C:\Program Files\PCL\3rdParty\VTK\include\vtk-6.3

Next, under the Configuration Properties > Linker > General > Additional Library Directories, the following library directories are added (based on the install directories I used above):

PCL - C:\Program Files\PCL\lib
PCL per Configuration - C:\Program Files\PCL\lib\$(Configuration)
Qt - C:\Qt\Qt5.5.1\5.5\msvc2013_64\lib
Boost - C:\Program Files\PCL\3rdParty\Boost\lib
Flann - C:\Program Files\PCL\3rdParty\Flann\lib
Qhull - C:\Program Files\PCL\3rdParty\Qhull\lib
VTK - C:\Program Files\PCL\3rdParty\VTK\lib 

Next, the library files used in the project are included in Configuration Properties > Linker > Input. The selection of which libraries to use depends on the scope of the project and the configuration used. Debug configurations usually have a postfix on the name of the library file, such as the _d or -gd used during the build process described in the previous sections. Some of the library files used include:

//Boost Library:
libboost_system-vc120-mt-gd-1_60.lib
libboost_filesystem-vc120-mt-gd-1_60.lib
libboost_thread-vc120-mt-gd-1_60.lib
libboost_date_time-vc120-mt-gd-1_60.lib
libboost_iostreams-vc120-mt-gd-1_60.lib

//PCL Library:
pcl_common_debug.lib
pcl_apps_debug.lib
pcl_features_debug.lib
pcl_filters_debug.lib
pcl_io_debug.lib
pcl_io_ply_debug.lib
pcl_kdtree_debug.lib
pcl_keypoints_debug.lib
pcl_octree_debug.lib
pcl_registration_debug.lib
pcl_sample_consensus_debug.lib
pcl_search_debug.lib
pcl_segmentation_debug.lib
pcl_surface_debug.lib
pcl_tracking_debug.lib
pcl_visualization_debug.lib

//VTK Library:
vtkRendering-gd.lib
QVTK-gd.lib
vtkalglib-gd.lib
vtkCharts-gd.lib
vtkCommon-gd.lib
vtkDICOMParser-gd.lib
vtkexoIIc-gd.lib
vtkexpat-gd.lib
vtkFiltering-gd.lib
vtkfreetype-gd.lib
vtkftgl-gd.lib
vtkGenericFiltering-gd.lib
vtkGeovis-gd.lib
vtkGraphics-gd.lib
vtkhdf5-gd.lib
vtkHybrid-gd.lib
vtkImaging-gd.lib
vtkInfovis-gd.lib
vtkIO-gd.lib
vtkjpeg-gd.lib
vtklibxml2-gd.lib
vtkmetaio-gd.lib
vtkNetCDF_cxx-gd.lib
vtkNetCDF-gd.lib
vtkpng-gd.lib
vtkproj4-gd.lib
vtksqlite-gd.lib
vtksys-gd.lib
vtktiff-gd.lib
vtkverdict-gd.lib
vtkViews-gd.lib
vtkVolumeRendering-gd.lib
vtkWidgets-gd.lib
vtkzlib-gd.lib
OpenGL32.Lib

The above libraries are for the Debug configuration, use the Release lib files when building under the Release configuration. For dependencies, these files are the files without the postfix -gd or _d. For the PCL library, the lib files will have a postfix of _release. Once all the configurations have been set, the project should be able to be to be built and run. An example of the resulting file is shown below:

# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z
SIZE 4 4 4
TYPE F F F
COUNT 1 1 1
WIDTH 5
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 5
DATA ascii
1.28125 577.09375 197.9375
828.125 599.03125 491.375
358.6875 917.4375 842.5625
764.5 178.28125 879.53125
727.53125 525.84375 311.28125

 


 

Advertisements

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