VS编译PCL1.8.0

参考1
参考2
提醒:
1、编译过程请联网!VS在编译VTK时需要自动下载一些文件,否则会编译失败!
2、第三方库最好都安装在默认目录。(也就是在后面cmake中设置CMAKE_INSTALL_PREFIX的值时,用默认目录)

1、准备

工具:
vs2012
cmake3.5.0

第三方库:
boost_1.60.0
eigen3.2.8
qhull_2015.2
VTK_7.0.0
flann_1.8.4
另外还可以根据需要下载安装microsoft mpi,在编译boost时,编译该功能。。。不需要就算啦。。。

2、开始

2.1编译boost

若需要mpi则首先下载安装它,然后到boost_1_60_0\tools\build\src\tools\mpi.jam中修改下面几行:
249-251 line

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 ]

260-262 line

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

268 line

.mpirun = "\"$(microsoft_mpi_path)\\Bin\\mpiexec.exe"\" ;

然后运行VS自带的cmd(“VS2012 x86 本机工具命令提示”),进入boost文件夹,运行bootstrap.bat,运行结束后会生成project-config.jam,打开并在第四行加上:using mpi ;(注意“;”前面有一个空格!) 接下来还是用cmd进入boost文件夹,运行如下命令编译boost:
Win32:
b2.exe toolset=msvc-11.0 address-model=32 –build-dir=build\x86 install –prefix=”C:\Program Files (x86)\Boost” -j8
X64:
b2.exe toolset=msvc-11.0 address-model=64 –build-dir=build\x64 install –prefix=”C:\Program Files\Boost” -j8
其中msvc-12.0代表vs2013,如果是11.0是vs2012,14.0是vs2015。后面的C:\Program Files\Boost是boost的安装文件夹。
然后等着就好了,时间有点久,耐心等。完成后在环境变量中建立BOOST_ROOT变量,值为boost文件夹安装地址C:\Program Files\Boost.

2.2编译eigen

使用cmake,分别设置eigen的source和build路径(source路径其实就是含有CMakeLists.txt的文件夹,其实就是source的根目录,我的路径是E:\pcl\Eigen),如build不存在,点击Configure会提示新建build文件夹,选择vs11-2012编译器,这里注意Configure时有CMAKE_INSTALL_PREFIX这个选项,默认为C:\Program Files\Eigen.这里的路径即为该软件最后的安装路径(也是环境变量中要设置的EIGEN_ROOT的路径,可设置为你想要的其它路径,后边的FLANN,QHULL,VTK也是一样道理).然后Generate。
之后**以管理员身份运行**VS2012(否则install时会失败),打开bulid文件夹下的eigen.sln工程,待加加完文件后,生成ALL_BUILD(Debug和 Release均要生成),完成后生成INSTALL(Debug and Release)。可以看到eigen安装路径中出现include文件夹。最后在环境变量中建立EIGEN_ROOT变量,值为eigen的安装路径。

2.3编译qhull

使用cmake,分别设置qhull的source和build路径,如build不存在,点击Configure会提示新建build文件夹,选择vs11-2012-win64编译器.注意根据需要修改CMAKE_INSTALL_PREFIX,然后添加一个entry:

Name: CMAKE_DEBUG_POSTFIX

Type: STRING

Value: -d

修改完后再次点Configure,然后Generate。以管理员身份运行VS2012并打开qhull.sln工程文件,待加载完文件后,完成后生成ALL_BUILD(debug和release),然后生成INSTALL(Debugand Release)。完成后可以看到qhull安装路径中出现include和lib文件夹。最后在环境变量中建立QHULL_ROOT变量,值为qhull安装地址。

2.4编译VTK

使用cmake,分别设置VTK的source和build路径,如build不存在,点击Configure会提示新建build文件夹,选择vs11-2012-win64编译器.注意根据需要修改CMAKE_INSTALL_PREFIX选项,然后添加一个entry:

Name: CMAKE_DEBUG_POSTFIX

Type: STRING

Value: -gd

修改完后再次点Configure,然后Generate。以管理员身份运行VS2012并打开VTK.sln工程文件,待加载完文件后,生成ALL_BUILD(debug和release)(时间有点久,很久,耐心等待),完成后生成install(debug和release)。完成后可以看到VTK文件夹中出现include和lib文件夹。最后在环境变量中建立VTK_ROOT,为VTK安装路径.

2.5编译flann

使用cmake,分别设置Flann的source和build路径(如C:\flann,C:\flann\build),选择vs12-2013编译器.注意根据需要修改CMAKE_INSTALL_PREFIX,然后添加一个entry:

Name: CMAKE_DEBUG_POSTFIX

Type: STRING

Value: -gd

修改完后再次点Configure,然后Generate。在C:\flann\src\cpp\flann\util(源码)中找到serialization.h文件 在92行BASIC_TYPE_SERIALIZER(bool)之后加入以下代码:

#ifdef _MSC_VER

BASIC_TYPE_SERIALIZER( unsigned __int64 );//注意此处__int64是两个下划线连一起

#endif

修改完后以管理员身份运行VS2012并打开flann.sln工程文件,待加载完文件后,(debug和release)生成all_build,完成后生成install(Debugand Release)。完成后可以看到flann安装路径下出现include和lib文件夹。最后在环境变量中建立FLANN_ROOT变量,值为flann安装路径。
(如果你按照上面的方法编译flann成功了,恭喜你。如果没成功,不要紧,直接下载个别人编译好的安装,这里有个版本比较老的)

2.6最后配置PCL

使用cmake选择source和build文件夹,such as:
Where is the source code: C:\PCL-master\source

Where is build the binaries: C:\PCL-master\build

点击Configure,选择vs11-2012-win64编译器,正常情况下不会出现什么问题,注意根据需要修改CMAKE_INSTALL_PREFIX(我的路径为C:\ProgramFiles\PCL),再次点击Configure,然后generate生成.以管理员身份运行VS2012并打开PCL.sln,生成ALL_BUILD(Debug和Release模式,各自得半小时左右).
随后生成INSTALL(Debug and Release)将PCL-1.8成功安装。

(在别人的博客中看到:
修改build文件夹中cmake_install.cmake修改第46行:
file(INSTALL DESTINATION”${CMAKE_INSTALL_PREFIX}/3rdParty/Boost” TYPE DIRECTORY FILES “C:/ProgramFiles/Boost/” REGEX “/[^/]*\/uninstall\.exe$” EXCLUDE) 其中C:/Program Files/Boost/为boost所在文件夹。
貌似可以讲库统统拷贝到pcl/3rdParty/Boost中。。。但是自己设置后不知为何,没鸟用。。。库还是在PCL源码目录下。。。。不管了,反正能用

最后在环境变量中建立PCL_ROOT变量,值为PCL安装路径。

下面是我测试时使用的属性表(并不完整,调试时找不到哪个头文件就加哪个吧。。。算作为参考)

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <IncludePath>D:\PCL\PCL_1_8_0\search\include;D:\PCL\PCL_1_8_0\geometry\include;D:\PCL\PCL_1_8_0\visualization\include;D:\PCL\PCL_1_8_0\io\include;D:\PCL\PCL_1_8_0\common\include;C:\Program Files\OpenNI2\Include;C:\Program Files\Eigen\include\eigen3;C:\Program Files\flann\include;C:\Program Files\VTK\include;C:\Program Files\VTK\include\vtk-7.0;C:\Program Files\Boost\include\boost-1_60;D:\PCL\PCL_1_8_0\recognition\include\pcl\recognition\3rdparty;D:\PCL\PCL_1_8_0\bulid\include;D:\PCL\PCL_1_8_0\bulid\include\pcl;D:\PCL\PCL_1_8_0;$(IncludePath)</IncludePath> <LibraryPath>C:\Program Files\OpenNI2\Lib;C:\Program Files\OpenNI2\Tools\OpenNI2;C:\Program Files\qhull\lib;D:\PCL\PCL_1_8_0\bulid\lib;C:\Program Files\Boost\lib;C:\Program Files\VTK\lib\cmake\vtk-7.0;C:\Program Files\flann\lib;$(LibraryPath)</LibraryPath>
  </PropertyGroup>
  <ItemDefinitionGroup>
    <ClCompile>
      <AdditionalIncludeDirectories>D:\PCL\PCL_1_8_0;C:\Program Files\VTK\include\vtk-7.0;C:\Program Files\qhull\include;C:\Program Files\Boost\include;C:\Program Files\flann\include;C:\Program Files\Eigen\include\eigen3;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;BOOST_DISABLE_ASSERTS;EIGEN_NO_DEBUG;BOOST_ALL_NO_LIB;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;NOMINMAX;PCL_ONLY_CORE_POINT_TYPES;__SSSE3__;__SSE2__;__SSE__;EIGEN_USE_NEW_STDVECTOR;EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET;FLANN_STATIC;vtkDomainsChemistry_AUTOINIT=1(vtkDomainsChemistryOpenGL2);vtkRenderingContext2D_AUTOINIT=1(vtkRenderingContextOpenGL2);vtkRenderingCore_INCLUDE="D:/PCL/PCL_1_8_0/bulid/CMakeFiles/vtkRenderingCore_AUTOINIT_vtkInteractionStyle_vtkRenderingFreeType_vtkRenderingOpenGL2.h";vtkRenderingVolume_AUTOINIT=1(vtkRenderingVolumeOpenGL2);BOOST_LIB_DIAGNOSTIC;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <AdditionalLibraryDirectories>C:\Program Files\OpenNI2\Lib;C:\Program Files\qhull\lib;C:\Program Files\VTK\lib\cmake\vtk-7.0;C:\Program Files\Boost\lib;C:\Program Files\flann\lib;D:\PCL\PCL_1_8_0\bulid\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
      <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib;C:\Program Files\Boost\lib\libboost_system-vc120-mt-gd-1_60.lib;C:\Program Files\Boost\lib\libboost_filesystem-vc120-mt-gd-1_60.lib;C:\Program Files\Boost\lib\libboost_thread-vc120-mt-gd-1_60.lib;C:\Program Files\Boost\lib\libboost_date_time-vc120-mt-gd-1_60.lib;C:\Program Files\Boost\lib\libboost_iostreams-vc120-mt-gd-1_60.lib;C:\Program Files\Boost\lib\libboost_chrono-vc120-mt-gd-1_60.lib;C:\Program Files\Boost\lib\libboost_atomic-vc120-mt-gd-1_60.lib;C:\Program Files\Boost\lib\libboost_regex-vc120-mt-gd-1_60.lib;pcl_visualization_debug.lib;pcl_io_debug.lib;pcl_io_ply_debug.lib;C:\Program Files\OpenNI2\Lib\OpenNI2.lib;pcl_kdtree_debug.lib;pcl_common_debug.lib;C:\Program Files\flann\lib\flann_cpp_s-gd.lib;C:\Program Files\VTK\lib\vtkDomainsChemistryOpenGL2-7.0-gd.lib;C:\Program Files\VTK\lib\vtkDomainsChemistry-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersFlowPaths-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersGeneric-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersHyperTree-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersParallelImaging-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersProgrammable-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersSelection-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersSMP-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersTexture-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersVerdict-7.0-gd.lib;C:\Program Files\VTK\lib\vtkverdict-7.0-gd.lib;C:\Program Files\VTK\lib\vtkGeovisCore-7.0-gd.lib;C:\Program Files\VTK\lib\vtkproj4-7.0-gd.lib;C:\Program Files\VTK\lib\vtkImagingMath-7.0-gd.lib;C:\Program Files\VTK\lib\vtkImagingMorphological-7.0-gd.lib;C:\Program Files\VTK\lib\vtkImagingStatistics-7.0-gd.lib;C:\Program Files\VTK\lib\vtkImagingStencil-7.0-gd.lib;C:\Program Files\VTK\lib\vtkInteractionImage-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOAMR-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersAMR-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOEnSight-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOExodus-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOExport-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOImport-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOInfovis-7.0-gd.lib;C:\Program Files\VTK\lib\vtklibxml2-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOLSDyna-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOMINC-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOMovie-7.0-gd.lib;C:\Program Files\VTK\lib\vtkoggtheora-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOParallel-7.0-gd.lib;C:\Program Files\VTK\lib\vtkexoIIc-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersParallel-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIONetCDF-7.0-gd.lib;C:\Program Files\VTK\lib\vtkNetCDF_cxx-7.0-gd.lib;C:\Program Files\VTK\lib\vtkNetCDF-7.0-gd.lib;C:\Program Files\VTK\lib\vtkhdf5_hl-7.0-gd.lib;C:\Program Files\VTK\lib\vtkhdf5-7.0-gd.lib;C:\Program Files\VTK\lib\vtkjsoncpp-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOParallelXML-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOXML-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOXMLParser-7.0-gd.lib;C:\Program Files\VTK\lib\vtkexpat-7.0-gd.lib;C:\Program Files\VTK\lib\vtkParallelCore-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOLegacy-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOPLY-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOGeometry-7.0-gd.lib;C:\Program Files\VTK\lib\vtksqlite-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOVideo-7.0-gd.lib;C:\Program Files\VTK\lib\vtkRenderingContextOpenGL2-7.0-gd.lib;C:\Program Files\VTK\lib\vtkRenderingImage-7.0-gd.lib;C:\Program Files\VTK\lib\vtkRenderingLOD-7.0-gd.lib;C:\Program Files\VTK\lib\vtkRenderingVolumeOpenGL2-7.0-gd.lib;C:\Program Files\VTK\lib\vtkRenderingOpenGL2-7.0-gd.lib;C:\Program Files\VTK\lib\vtkglew-7.0-gd.lib;C:\Program Files\VTK\lib\vtkTestingGenericBridge-7.0-gd.lib;C:\Program Files\VTK\lib\vtkTestingIOSQL-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOSQL-7.0-gd.lib;C:\Program Files\VTK\lib\vtkTestingRendering-7.0-gd.lib;C:\Program Files\VTK\lib\vtkViewsContext2D-7.0-gd.lib;C:\Program Files\VTK\lib\vtkViewsInfovis-7.0-gd.lib;C:\Program Files\VTK\lib\vtkChartsCore-7.0-gd.lib;C:\Program Files\VTK\lib\vtkRenderingContext2D-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersImaging-7.0-gd.lib;C:\Program Files\VTK\lib\vtkInfovisLayout-7.0-gd.lib;C:\Program Files\VTK\lib\vtkInfovisCore-7.0-gd.lib;C:\Program Files\VTK\lib\vtkViewsCore-7.0-gd.lib;C:\Program Files\VTK\lib\vtkInteractionWidgets-7.0-gd.lib;C:\Program Files\VTK\lib\vtkImagingHybrid-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOImage-7.0-gd.lib;C:\Program Files\VTK\lib\vtkDICOMParser-7.0-gd.lib;C:\Program Files\VTK\lib\vtkIOCore-7.0-gd.lib;C:\Program Files\VTK\lib\vtkmetaio-7.0-gd.lib;comctl32.lib;wsock32.lib;C:\Program Files\VTK\lib\vtkpng-7.0-gd.lib;C:\Program Files\VTK\lib\vtktiff-7.0-gd.lib;C:\Program Files\VTK\lib\vtkjpeg-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersHybrid-7.0-gd.lib;C:\Program Files\VTK\lib\vtkImagingGeneral-7.0-gd.lib;C:\Program Files\VTK\lib\vtkImagingSources-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersModeling-7.0-gd.lib;C:\Program Files\VTK\lib\vtkInteractionStyle-7.0-gd.lib;C:\Program Files\VTK\lib\vtkRenderingAnnotation-7.0-gd.lib;C:\Program Files\VTK\lib\vtkImagingColor-7.0-gd.lib;C:\Program Files\VTK\lib\vtkRenderingVolume-7.0-gd.lib;C:\Program Files\VTK\lib\vtkRenderingLabel-7.0-gd.lib;C:\Program Files\VTK\lib\vtkRenderingFreeType-7.0-gd.lib;C:\Program Files\VTK\lib\vtkRenderingCore-7.0-gd.lib;C:\Program Files\VTK\lib\vtkCommonColor-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersExtraction-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersStatistics-7.0-gd.lib;C:\Program Files\VTK\lib\vtkalglib-7.0-gd.lib;C:\Program Files\VTK\lib\vtkImagingFourier-7.0-gd.lib;C:\Program Files\VTK\lib\vtkImagingCore-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersGeometry-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersSources-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersGeneral-7.0-gd.lib;C:\Program Files\VTK\lib\vtkFiltersCore-7.0-gd.lib;C:\Program Files\VTK\lib\vtkCommonExecutionModel-7.0-gd.lib;C:\Program Files\VTK\lib\vtkCommonComputationalGeometry-7.0-gd.lib;C:\Program Files\VTK\lib\vtkCommonDataModel-7.0-gd.lib;C:\Program Files\VTK\lib\vtkCommonMisc-7.0-gd.lib;C:\Program Files\VTK\lib\vtkCommonTransforms-7.0-gd.lib;C:\Program Files\VTK\lib\vtkCommonMath-7.0-gd.lib;C:\Program Files\VTK\lib\vtkCommonSystem-7.0-gd.lib;C:\Program Files\VTK\lib\vtkCommonCore-7.0-gd.lib;C:\Program Files\VTK\lib\vtksys-7.0-gd.lib;ws2_32.lib;Psapi.lib;C:\Program Files\VTK\lib\vtkfreetype-7.0-gd.lib;C:\Program Files\VTK\lib\vtkzlib-7.0-gd.lib;glu32.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup />
</Project>

你可能感兴趣的:(vs,cmake,PCL)