Windows11+VS2022+PCL1.13.0 安装配置记录
下载PCL AllInOne 安装包安装 PCLOpenNI2 安装确认系统环境变量配置Visual Studio环境配置1. C/C++ -- 所有选项 -- SDL检查 -- 设置为**否**2. VC++目录 -- 包含目录 -- 编辑 --添加新的目录如下3. VC++目录 -- 库目录 -- 编辑 --添加新的目录如下4. C/C++ -- 预处理器 -- 预处理器定义 -- 编辑 --添加预处理器定义如下5. 链接器 -- 输入 -- 附加依赖项 -- 编辑6. C/C++ – 代码生成 – 启用增强指令集 – 选择高级矢量扩展7. 项目--属性--调试--环境--编辑---添加环境如下 PCL 测试
下载PCL AllInOne 安装包
在release页面下载和自己电脑上VS版本对应的AllInOne exe
安装 PCL
双击下载的AllInOne exe
这里选择给所有用户添加环境变量
老规矩,安装目录改到D盘。
所有依赖都装。
waiting…几分钟的样子
win11还有这玩意儿
环境变量写入失败,无所谓,等会儿自己加。
完成。
OpenNI2 安装确认
进入安装目录下的3rdParty检查OpenNI2有没有安装,一般都会安装到C盘,打开C盘的Program Files文件夹,果然,它直接安装到了C盘,并且还自动写入了环境变量。
由于强迫症的关系,决定把它重装在D盘。在该PCL安装路径下的3rdParty/OpenNI2可以看到安装包,双击打开。
remove卸载掉原有安装
卸载完成,重新双击安装,更改安装位置
很快就安装完成了。
系统环境变量配置
首先是OpenNI2的环境变量,因为在安装时已经写入了PCL_ROOT这个环境变量,所以OpenNI2环境变量可以改为如下形式
然后打开Path,添加
%PCL_ROOT%\bin%PCL_ROOT%\3rdParty\VTK\bin%PCL_ROOT%\3rdParty\FLANN\bin%PCL_ROOT%\3rdParty\OpenNI2\Tools%PCL_ROOT%\3rdParty\Qhull\bin%OPENNI2_REDIST64%%OPENNI2_LIB64%%OPENNI2_INCLUDE64%
Visual Studio环境配置
创建一个新项目PCL_test,打开属性管理器,先配置x64 的Release,新建属性表,命名为 PCL1.13_Release_x64.props。
双击该属性表,开始配置
1. C/C++ – 所有选项 – SDL检查 – 设置为否
2. VC++目录 – 包含目录 – 编辑 --添加新的目录如下
D:\Program Files (x86)\PCL 1.13.0\include\pcl-1.13D:\Program Files (x86)\PCL 1.13.0\3rdParty\Boost\include\boost-1_80D:\Program Files (x86)\PCL 1.13.0\3rdParty\Eigen\eigen3D:\Program Files (x86)\PCL 1.13.0\3rdParty\FLANN\includeD:\Program Files (x86)\PCL 1.13.0\3rdParty\OpenNI2\IncludeD:\Program Files (x86)\PCL 1.13.0\3rdParty\Qhull\includeD:\Program Files (x86)\PCL 1.13.0\3rdParty\VTK\include\vtk-9.2
3. VC++目录 – 库目录 – 编辑 --添加新的目录如下
D:\Program Files (x86)\PCL 1.13.0\libD:\Program Files (x86)\PCL 1.13.0\3rdParty\Boost\libD:\Program Files (x86)\PCL 1.13.0\3rdParty\FLANN\libD:\Program Files (x86)\PCL 1.13.0\3rdParty\OpenNI2\LibD:\Program Files (x86)\PCL 1.13.0\3rdParty\Qhull\libD:\Program Files (x86)\PCL 1.13.0\3rdParty\VTK\lib
4. C/C++ – 预处理器 – 预处理器定义 – 编辑 --添加预处理器定义如下
BOOST_USE_WINDOWS_HNOMINMAX_CRT_SECURE_NO_DEPRECATE
5. 链接器 – 输入 – 附加依赖项 – 编辑
这里需要对PCL和VTK的lib进行提取,Release和Debug所需的lib不一样,Debug是 **d.lib 类型,Release是 *.lib 类型。之前我写了一个简单的小脚本来自动提取两种lib。(当然也可以通过手动输入或其他方式获取相应lib。)脚本代码如下
# File :Extract_lib_to_txt.py# Auther :WooChi# Time :2022/06/08# Version :1.0# Function :自动提取lib文件夹下的.lib文件,根据文件名分别导出到release_lib.txt和debug_lib.txt中import osdef Extract_lib(path): release = open("release_lib.txt", 'w') debug = open("debug_lib.txt", 'w') for file in os.listdir(path): if file[-5:] == 'd.lib': debug.write(file) debug.write('\n') elif file[-4:] == '.lib': release.write(file) release.write('\n') debug.close() release.close()if __name__ == '__main__': path = r"D:\Program Files (x86)\OPenCV\x64\vc16\lib" Extract_lib(path)
先提取VTK的lib,结果如下
vtk_debug_lib.txt
vtkcgns-9.2-gd.libvtkChartsCore-9.2-gd.libvtkCommonColor-9.2-gd.libvtkCommonComputationalGeometry-9.2-gd.libvtkCommonCore-9.2-gd.libvtkCommonDataModel-9.2-gd.libvtkCommonExecutionModel-9.2-gd.libvtkCommonMath-9.2-gd.libvtkCommonMisc-9.2-gd.libvtkCommonSystem-9.2-gd.libvtkCommonTransforms-9.2-gd.libvtkDICOMParser-9.2-gd.libvtkDomainsChemistry-9.2-gd.libvtkDomainsChemistryOpenGL2-9.2-gd.libvtkdoubleconversion-9.2-gd.libvtkexodusII-9.2-gd.libvtkexpat-9.2-gd.libvtkFiltersAMR-9.2-gd.libvtkFiltersCore-9.2-gd.libvtkFiltersExtraction-9.2-gd.libvtkFiltersFlowPaths-9.2-gd.libvtkFiltersGeneral-9.2-gd.libvtkFiltersGeneric-9.2-gd.libvtkFiltersGeometry-9.2-gd.libvtkFiltersHybrid-9.2-gd.libvtkFiltersHyperTree-9.2-gd.libvtkFiltersImaging-9.2-gd.libvtkFiltersModeling-9.2-gd.libvtkFiltersParallel-9.2-gd.libvtkFiltersParallelImaging-9.2-gd.libvtkFiltersPoints-9.2-gd.libvtkFiltersProgrammable-9.2-gd.libvtkFiltersSelection-9.2-gd.libvtkFiltersSMP-9.2-gd.libvtkFiltersSources-9.2-gd.libvtkFiltersStatistics-9.2-gd.libvtkFiltersTexture-9.2-gd.libvtkFiltersTopology-9.2-gd.libvtkFiltersVerdict-9.2-gd.libvtkfmt-9.2-gd.libvtkfreetype-9.2-gd.libvtkGeovisCore-9.2-gd.libvtkgl2ps-9.2-gd.libvtkglew-9.2-gd.libvtkhdf5-9.2-gd.libvtkhdf5_hl-9.2-gd.libvtkImagingColor-9.2-gd.libvtkImagingCore-9.2-gd.libvtkImagingFourier-9.2-gd.libvtkImagingGeneral-9.2-gd.libvtkImagingHybrid-9.2-gd.libvtkImagingMath-9.2-gd.libvtkImagingMorphological-9.2-gd.libvtkImagingSources-9.2-gd.libvtkImagingStatistics-9.2-gd.libvtkImagingStencil-9.2-gd.libvtkInfovisCore-9.2-gd.libvtkInfovisLayout-9.2-gd.libvtkInteractionImage-9.2-gd.libvtkInteractionStyle-9.2-gd.libvtkInteractionWidgets-9.2-gd.libvtkIOAMR-9.2-gd.libvtkIOAsynchronous-9.2-gd.libvtkIOCesium3DTiles-9.2-gd.libvtkIOCGNSReader-9.2-gd.libvtkIOChemistry-9.2-gd.libvtkIOCityGML-9.2-gd.libvtkIOCONVERGECFD-9.2-gd.libvtkIOCore-9.2-gd.libvtkIOEnSight-9.2-gd.libvtkIOExodus-9.2-gd.libvtkIOExport-9.2-gd.libvtkIOExportGL2PS-9.2-gd.libvtkIOExportPDF-9.2-gd.libvtkIOGeometry-9.2-gd.libvtkIOHDF-9.2-gd.libvtkIOImage-9.2-gd.libvtkIOImport-9.2-gd.libvtkIOInfovis-9.2-gd.libvtkIOIOSS-9.2-gd.libvtkIOLegacy-9.2-gd.libvtkIOLSDyna-9.2-gd.libvtkIOMINC-9.2-gd.libvtkIOMotionFX-9.2-gd.libvtkIOMovie-9.2-gd.libvtkIONetCDF-9.2-gd.libvtkIOOggTheora-9.2-gd.libvtkIOParallel-9.2-gd.libvtkIOParallelXML-9.2-gd.libvtkIOPLY-9.2-gd.libvtkIOSegY-9.2-gd.libvtkIOSQL-9.2-gd.libvtkioss-9.2-gd.libvtkIOTecplotTable-9.2-gd.libvtkIOVeraOut-9.2-gd.libvtkIOVideo-9.2-gd.libvtkIOXML-9.2-gd.libvtkIOXMLParser-9.2-gd.libvtkjpeg-9.2-gd.libvtkjsoncpp-9.2-gd.libvtkkissfft-9.2-gd.libvtklibharu-9.2-gd.libvtklibproj-9.2-gd.libvtklibxml2-9.2-gd.libvtkloguru-9.2-gd.libvtklz4-9.2-gd.libvtklzma-9.2-gd.libvtkmetaio-9.2-gd.libvtknetcdf-9.2-gd.libvtkogg-9.2-gd.libvtkParallelCore-9.2-gd.libvtkParallelDIY-9.2-gd.libvtkpng-9.2-gd.libvtkpugixml-9.2-gd.libvtkRenderingAnnotation-9.2-gd.libvtkRenderingContext2D-9.2-gd.libvtkRenderingContextOpenGL2-9.2-gd.libvtkRenderingCore-9.2-gd.libvtkRenderingFreeType-9.2-gd.libvtkRenderingGL2PSOpenGL2-9.2-gd.libvtkRenderingHyperTreeGrid-9.2-gd.libvtkRenderingImage-9.2-gd.libvtkRenderingLabel-9.2-gd.libvtkRenderingLICOpenGL2-9.2-gd.libvtkRenderingLOD-9.2-gd.libvtkRenderingOpenGL2-9.2-gd.libvtkRenderingSceneGraph-9.2-gd.libvtkRenderingUI-9.2-gd.libvtkRenderingVolume-9.2-gd.libvtkRenderingVolumeOpenGL2-9.2-gd.libvtkRenderingVtkJS-9.2-gd.libvtksqlite-9.2-gd.libvtksys-9.2-gd.libvtkTestingRendering-9.2-gd.libvtktheora-9.2-gd.libvtktiff-9.2-gd.libvtkverdict-9.2-gd.libvtkViewsContext2D-9.2-gd.libvtkViewsCore-9.2-gd.libvtkViewsInfovis-9.2-gd.libvtkWrappingTools-9.2-gd.libvtkzlib-9.2-gd.lib
vtk_release_lib.txt
vtkcgns-9.2.libvtkChartsCore-9.2.libvtkCommonColor-9.2.libvtkCommonComputationalGeometry-9.2.libvtkCommonCore-9.2.libvtkCommonDataModel-9.2.libvtkCommonExecutionModel-9.2.libvtkCommonMath-9.2.libvtkCommonMisc-9.2.libvtkCommonSystem-9.2.libvtkCommonTransforms-9.2.libvtkDICOMParser-9.2.libvtkDomainsChemistry-9.2.libvtkDomainsChemistryOpenGL2-9.2.libvtkdoubleconversion-9.2.libvtkexodusII-9.2.libvtkexpat-9.2.libvtkFiltersAMR-9.2.libvtkFiltersCore-9.2.libvtkFiltersExtraction-9.2.libvtkFiltersFlowPaths-9.2.libvtkFiltersGeneral-9.2.libvtkFiltersGeneric-9.2.libvtkFiltersGeometry-9.2.libvtkFiltersHybrid-9.2.libvtkFiltersHyperTree-9.2.libvtkFiltersImaging-9.2.libvtkFiltersModeling-9.2.libvtkFiltersParallel-9.2.libvtkFiltersParallelImaging-9.2.libvtkFiltersPoints-9.2.libvtkFiltersProgrammable-9.2.libvtkFiltersSelection-9.2.libvtkFiltersSMP-9.2.libvtkFiltersSources-9.2.libvtkFiltersStatistics-9.2.libvtkFiltersTexture-9.2.libvtkFiltersTopology-9.2.libvtkFiltersVerdict-9.2.libvtkfmt-9.2.libvtkfreetype-9.2.libvtkGeovisCore-9.2.libvtkgl2ps-9.2.libvtkglew-9.2.libvtkhdf5-9.2.libvtkhdf5_hl-9.2.libvtkImagingColor-9.2.libvtkImagingCore-9.2.libvtkImagingFourier-9.2.libvtkImagingGeneral-9.2.libvtkImagingHybrid-9.2.libvtkImagingMath-9.2.libvtkImagingMorphological-9.2.libvtkImagingSources-9.2.libvtkImagingStatistics-9.2.libvtkImagingStencil-9.2.libvtkInfovisCore-9.2.libvtkInfovisLayout-9.2.libvtkInteractionImage-9.2.libvtkInteractionStyle-9.2.libvtkInteractionWidgets-9.2.libvtkIOAMR-9.2.libvtkIOAsynchronous-9.2.libvtkIOCesium3DTiles-9.2.libvtkIOCGNSReader-9.2.libvtkIOChemistry-9.2.libvtkIOCityGML-9.2.libvtkIOCONVERGECFD-9.2.libvtkIOCore-9.2.libvtkIOEnSight-9.2.libvtkIOExodus-9.2.libvtkIOExport-9.2.libvtkIOExportGL2PS-9.2.libvtkIOExportPDF-9.2.libvtkIOGeometry-9.2.libvtkIOHDF-9.2.libvtkIOImage-9.2.libvtkIOImport-9.2.libvtkIOInfovis-9.2.libvtkIOIOSS-9.2.libvtkIOLegacy-9.2.libvtkIOLSDyna-9.2.libvtkIOMINC-9.2.libvtkIOMotionFX-9.2.libvtkIOMovie-9.2.libvtkIONetCDF-9.2.libvtkIOOggTheora-9.2.libvtkIOParallel-9.2.libvtkIOParallelXML-9.2.libvtkIOPLY-9.2.libvtkIOSegY-9.2.libvtkIOSQL-9.2.libvtkioss-9.2.libvtkIOTecplotTable-9.2.libvtkIOVeraOut-9.2.libvtkIOVideo-9.2.libvtkIOXML-9.2.libvtkIOXMLParser-9.2.libvtkjpeg-9.2.libvtkjsoncpp-9.2.libvtkkissfft-9.2.libvtklibharu-9.2.libvtklibproj-9.2.libvtklibxml2-9.2.libvtkloguru-9.2.libvtklz4-9.2.libvtklzma-9.2.libvtkmetaio-9.2.libvtknetcdf-9.2.libvtkogg-9.2.libvtkParallelCore-9.2.libvtkParallelDIY-9.2.libvtkpng-9.2.libvtkpugixml-9.2.libvtkRenderingAnnotation-9.2.libvtkRenderingContext2D-9.2.libvtkRenderingContextOpenGL2-9.2.libvtkRenderingCore-9.2.libvtkRenderingFreeType-9.2.libvtkRenderingGL2PSOpenGL2-9.2.libvtkRenderingHyperTreeGrid-9.2.libvtkRenderingImage-9.2.libvtkRenderingLabel-9.2.libvtkRenderingLICOpenGL2-9.2.libvtkRenderingLOD-9.2.libvtkRenderingOpenGL2-9.2.libvtkRenderingSceneGraph-9.2.libvtkRenderingUI-9.2.libvtkRenderingVolume-9.2.libvtkRenderingVolumeOpenGL2-9.2.libvtkRenderingVtkJS-9.2.libvtksqlite-9.2.libvtksys-9.2.libvtkTestingRendering-9.2.libvtktheora-9.2.libvtktiff-9.2.libvtkverdict-9.2.libvtkViewsContext2D-9.2.libvtkViewsCore-9.2.libvtkViewsInfovis-9.2.libvtkWrappingTools-9.2.libvtkzlib-9.2.lib
再提取PCL的lib,结果如下
pcl_debug_lib.txt
pcl_commond.libpcl_featuresd.libpcl_filtersd.libpcl_iod.libpcl_io_plyd.libpcl_kdtreed.libpcl_keypointsd.libpcl_mld.libpcl_octreed.libpcl_outofcored.libpcl_peopled.libpcl_recognitiond.libpcl_registrationd.libpcl_sample_consensusd.libpcl_searchd.libpcl_segmentationd.libpcl_stereod.libpcl_surfaced.libpcl_trackingd.libpcl_visualizationd.lib
pcl_release_lib.txt
pcl_common.libpcl_features.libpcl_filters.libpcl_io.libpcl_io_ply.libpcl_kdtree.libpcl_keypoints.libpcl_ml.libpcl_octree.libpcl_outofcore.libpcl_people.libpcl_recognition.libpcl_registration.libpcl_sample_consensus.libpcl_search.libpcl_segmentation.libpcl_stereo.libpcl_surface.libpcl_tracking.libpcl_visualization.lib
现在在附加依赖项里输入Release版的lib(Debug版属性表主要在这一步不一样,可以通过复制Release版属性表的方式添加现有属性表修改或者新建属性表重新配置,我就不再啰嗦了)
6. C/C++ – 代码生成 – 启用增强指令集 – 选择高级矢量扩展
这一步与Eigen库相关,不加上的话程序在使用Eigen库时可能出现中断。
点击右下角应用,确定保存属性表
然后,还有重要的一步,亲测如果没有这一步,会出现找不到 pcl_***.dll 的报错信息
7. 项目–属性–调试–环境–编辑—添加环境如下
PATH=$(PCL_ROOT)\bin;$(PCL_ROOT)\3rdParty\FLANN\bin;$(PCL_ROOT)\3rdParty\VTK\bin;$(PCL_ROOT)\3rdParty\Qhull\bin;$(PCL_ROOT)\3rdParty\OpenNI2\Tools;$(PATH)
小伙伴说找不到环境位置,补了一个图在这儿。
接下来可以开始测试了。
PCL 测试
随便找一份测试代码
#include <iostream>#include <pcl/common/common_headers.h>#include <pcl/io/pcd_io.h>#include <pcl/visualization/pcl_visualizer.h>#include <pcl/visualization/cloud_viewer.h>#include <pcl/console/parse.h> int main(int argc, char **argv) { std::cout << "Test PCL !!!" << std::endl; pcl::PointCloud<pcl::PointXYZRGB>::Ptr point_cloud_ptr (new pcl::PointCloud<pcl::PointXYZRGB>); uint8_t r(255), g(15), b(15); for (float z(-1.0); z <= 1.0; z += 0.05) { for (float angle(0.0); angle <= 360.0; angle += 5.0) {pcl::PointXYZRGB point;point.x = 0.5 * cosf (pcl::deg2rad(angle));point.y = sinf (pcl::deg2rad(angle));point.z = z;uint32_t rgb = (static_cast<uint32_t>(r) << 16 |static_cast<uint32_t>(g) << 8 | static_cast<uint32_t>(b));point.rgb = *reinterpret_cast<float*>(&rgb);point_cloud_ptr->points.push_back (point); } if (z < 0.0) {r -= 12;g += 12; } else {g -= 12;b += 12; } } point_cloud_ptr->width = (int) point_cloud_ptr->points.size (); point_cloud_ptr->height = 1; pcl::visualization::CloudViewer viewer ("test"); viewer.showCloud(point_cloud_ptr); while (!viewer.wasStopped()){ }; return 0; }
执行成功
打完收工。