PCL on Windows. Compiling from sources



These days I wanted to work with pcl but the guides about using it on Windows were out-of-date or not precise at all, oblying me to work on linux.
([UPDATE:2015-12-19. Now, there is a nice official guide, http://www.pointclouds.org/documentation/tutorials/compiling_pcl_windows.php)

Finally when I got it I decided to share the whole proccess that I follow in order to help people with the same trouble like me. These are the steps:


  • Build zlib
    • Extract zip into pcl_build folder, go inside the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.
    • Go to build folder, open zlib.sln.
    • Choose build type (preferable "Release").
    • In project explorer, right click "ALL_BUILD" project and press "Build"
    • Wait until build finished.
    • In project explorer, right click "INSTALL" project and press "Build". (Note: in order to call INSTALL from Visual Studio (VS), it's needed to open it as administrator)
  • Build libpng
    • Extract zip into pcl_build folder, go inside the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.
    • Go to build folder, open libpng.sln.
    • Choose build type (preferable "Release").
    • In project explorer, right click "ALL_BUILD" project and press "Build"
    • Wait until build finished.
    • In project explorer, right click "INSTALL" project and press "Build"
  • Build eigen
    • Extract zip into pcl_build folder, go inside the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.
    • Go to build folder, open eigen.sln.
    • Choose build type (preferable "Release").
    • In project explorer, right click "ALL_BUILD" project and press "Build"
    • Wait until build finished.
    • In project explorer, right click "INSTALL" project and press "Build"
  • Build boost
    • Extract zip into pcl_build folder, go inside the folder. Make sure u are in the same root as "CMakeLists.txt" file
    • Open cmd terminal. Type: ".\bootstrap.bat" this will generate a file for building everything.
    • Type ".\b2 variant=release install" to build and install boost. If want to compile PCL in debug, compile boost in debug too. (It's possible to have both versions)
    • Now is necessary to add to system variables "BOOST_ROOT" with value "C:\Boost\include\boost-1_60" (or similar, depending on the version and the place you installed it)
  • Build flann
    • Extract zip into pcl_build folder (or clone repository), go inside the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.
    • Go to build folder, open flann.sln.
    • Choose build type (preferable "Release").
    • In project explorer, right click "ALL_BUILD" project and press "Build"
      • Troubleshooting: If compiler throw this (or similar error) error: "flann windows serializer has already been defined". Open file "C:\programming\pcl_build\flann\src\cpp\flann\util\serialization.h" and change lines 96-115 to:
BASIC_TYPE_SERIALIZER(char);
BASIC_TYPE_SERIALIZER(unsigned char);
BASIC_TYPE_SERIALIZER(short);
BASIC_TYPE_SERIALIZER(unsigned short);
BASIC_TYPE_SERIALIZER(int);
BASIC_TYPE_SERIALIZER(unsigned int);
 BASIC_TYPE_SERIALIZER(long);
BASIC_TYPE_SERIALIZER(unsigned long);
//BASIC_TYPE_SERIALIZER(unsigned long long);
BASIC_TYPE_SERIALIZER(float);
BASIC_TYPE_SERIALIZER(double);
BASIC_TYPE_SERIALIZER(bool);
#ifdef _MSC_VER
// unsigned __int64 ~= unsigned long long // Will throw error on VS2013&
//#if _MSC_VER != 1800&
BASIC_TYPE_SERIALIZER(unsigned __int64);
#else
BASIC_TYPE_SERIALIZER(unsigned long long);
#endif

    • Wait until build finished.
    • In project explorer, right click "INSTALL" project and press "Build"
    • If you see an error in a package related with matlab (see output and there should be a link to mathworks) dont worry about it, that package is not needed for PCL. It's possible to avoid compiling it disabling that module using cmake-gui.
  • Build qhull
    • Extract zip into pcl_build folder, go into the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.

    • Go to build folder, open qhull.sln.
    • Choose build type (preferable "Release").
    • In project explorer, right click "ALL_BUILD" project and press "Build"
    • Wait until build finished.
    • In project explorer, right click "INSTALL" project and press "Build"
  • Build Gtest. This library is only needed if want to compile tests. If you dont really care tests, disable option "BUILD_global_tests" in cmake.
    • Clone repository and go inside the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.

    • Go to build folder, open googletest-distribution.sln.
    • Choose build type (preferable "Release").
    • In project explorer, right click "ALL_BUILD" project and press "Build"
    • Wait until build finished.
    • In project explorer, right click "INSTALL" project and press "Build"
  • Build vtk
    • Extract zip into pcl_build folder, go inside the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.
    • Go to build folder, open vtk.sln.
    • Choose build type (preferable "Release").
    • In project explorer, right click "ALL_BUILD" project and press "Build"
    • Wait until build finished.
    • In project explorer, right clic "INSTALL" project and press "Build"
    • In order to let PCL find VTK, add "VTK_DIR" variable to system containing path to VTK folder (4 ex, "C:\Program Files (x86)\VTK").
  • Build PCL
    • Extract zip into pcl_build folder, go inside the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.
    • Go to build folder, open pcl.sln.
    • Choose build type. (Take care, before compiling pcl in any form, make sure that also has boost with that type of compilation).
    • In project explorer, right click "ALL_BUILD" project and press "Build"
    • Wait until build finished.
    • In project explorer, right click "INSTALL" project and press "Build"
  • Finally in order to allow new projects to find dinamyc libraries add following path to "System path variable"
    • libpng bin directory. 4 ex: "C:\Program Files (x86)\libpng\bin"
    • zlib bin directory. 4 ex: "C:\Program Files (x86)\zlib\bin"
    • flann bin directory. 4 ex: "C:\Program Files (x86)\flann\bin"
    • qhull bin directory. 4 ex: "C:\Program Files (x86)\qhull\bin"
    • vtk bin directory. 4 ex: "C:\Program Files (x86)\VTK\bin"
    • pl bin directory. 4 ex: "C:\Program Files (x86)\PCL\bin"


  • To use PCL in own project using cmake, add following:
find_package(PCL 1.2) // Or other version. 
include_directories(${PCL_INCLUDE_DIRS}) 
link_directories(${PCL_LIBRARY_DIRS}) 
add_definitions(${PCL_DEFINITIONS}) 
add_executable(testExe ${SOURCE_FILES}) 
target_link_libraries(testExe LINK_PUBLIC ${PCL_LIBRARIES})

  • Troubleshooting. Other possible errors.
    • "correspondence.h(75): warning C4003: not enough actual parameters for macro 'max'" or similar. This error means that "max" macro (And also "min" macro) of std collide with other definition of it (For example, with Eigen one). This error can be avoided adding following lines in the beginning of the headers that throw that errors:
#ifdef max 
#undef max 
#endif 
#ifdef min 
#undef min 
#endif

    • Cant find Boost: This error can arise from many reasons
      • Depend on cmake version, it's possible that your boost version is listed internally. Go to file "C:\Program Files (x86)\CMake\share\cmake-3.4\Modules\FindBoost.cmake" (check cmake instalation folder). Go to lines 514-522. Check if your version is in that list. If not, add it.
      • If previous point do not solve your trouble add this two variables to your Environment Variable System:
        • BOOST_DIR = C:\Boost
        • BOOST_INCLUDE_DIR = C:\Boost\include
    • "Cannot open include file: 'vtkgl.h': No such file or directory": This means that VTK has not generated properly that file. The vtkgl.h include file contains all the constants and function namespace safe way.  vtkgl.h is built from parsed glext.h, glxext.h, and You can also grep vtkgl.h (which will be in the binary build directory  (which will be in the binary build directory if VTK is not installed) for appropriate names.  There are also special extensions GL_VERSION_X_X (where X_X is replaced with a major and minor version, respectively) which contain all the constants and functions for OpenGL versions for which the gl.h header file is of an older version than the driver.
      • It is suppose to be generated, so firstly, try to remove all vtk  files, and call cmake again. Before recompiling VTK check that the file exists.
      • If problem persist, put a comment I'll try to help you.
PLEASE, don't doubt to put a comment if need some help, some step is missing or you think that something has changed!

No hay comentarios:

Publicar un comentario