PCL1.8的那些坑!各种编译及使用问题汇总

   在win10上用vs2013编译及使用pcl180遇见了各种坑,这里做个汇总,既是总结,也希望能给后来人引路!

1.编译到visualization模块的时候,会有如下语句报错:

if (!pcl::visualization::getColormapLUT (static_cast<LookUpTableRepresentationProperties>(value), table))
    break;

解决方案:
将所有的

static_cast<LookUpTableRepresentationProperties>(value)

修改成

static_cast<LookUpTableRepresentationProperties>(int(value))

2.编译官方教程中ICP例子时,出现下列错误:

error C4996: 'pcl::SAC_SAMPLE_SIZE': This map is deprecated and is kept only to prevent breaking existing user code. Starting from PCL 1.8.0 model sample size is a protected member of the SampleConsensusModel class

解决方案
打开项目属性页->C/C+±>常规->SDL检查(设置为否)
PCL1.8的那些坑!各种编译及使用问题汇总_第1张图片
若上面的方案无法解决这个错误,可以打开头文件“model_types.h”,修改其中的代码:
源码:

namespace pcl
{
  const static std::map<pcl::SacModel, unsigned int>
      PCL_DEPRECATED("This map is deprecated and is kept only to prevent breaking "
      "existing user code. Starting from PCL 1.8.0 model sample size "
      "is a protected member of the SampleConsensusModel class")
  SAC_SAMPLE_SIZE (sample_size_pairs, sample_size_pairs + sizeof (sample_size_pairs) / sizeof (SampleSizeModel));
}

修改后:

namespace pcl
{
  const static std::map<pcl::SacModel, unsigned int>
      //PCL_DEPRECATED("This map is deprecated and is kept only to prevent breaking "
      //"existing user code. Starting from PCL 1.8.0 model sample size "
      //"is a protected member of the SampleConsensusModel class")
  SAC_SAMPLE_SIZE (sample_size_pairs, sample_size_pairs + sizeof (sample_size_pairs) / sizeof (SampleSizeModel));
}

重新编译即可解决问题

3.错误信息

conditional_euclidean_clustering.obj : error LNK2001: 无法解析的外部符号 "public: void __cdecl pcl::ConditionalEuclideanClustering::segment(class std::vector > &)" (?segment@?$ConditionalEuclideanClustering@UPointXYZINormal@pcl@@@pcl@@QEAAXAEAV?$vector@UPointIndices@pcl@@V?$allocator@UPointIndices@pcl@@@std@@@std@@@Z)
1>conditional_euclidean_clustering.obj : error LNK2001: 无法解析的外部符号 "protected: virtual void __cdecl pcl::NormalEstimation::computeFeature(class pcl::PointCloud &)" (?computeFeature@?$NormalEstimation@UPointXYZI@pcl@@UPointXYZINormal@2@@pcl@@MEAAXAEAV?$PointCloud@UPointXYZINormal@pcl@@@2@@Z)
1>E:\VisualStudio2013Project\PCLConsoleApplication\x64\Release\ConditionalEuclideanClustering.exe : fatal error LNK1120: 2 个无法解析的外部命令

在所有库都配置的情况下,若出现上述问题
解决方法
打开项目属性页>C/C++>预处理器,添加:

_CRT_SECURE_NO_WARNINGS

4.错误信息

e:\shizhenwei\vs2013projects\testicp1\testicp1\main.cpp(39): error C4996: 'pcl::Registration::setInputCloud': [pcl::registration::Registration::setInputCloud] setInputCloud is deprecated. Please use setInputSource instead.
1>          with
1>          [
1>              PointSource=pcl::PointXYZ
1>  ,            PointTarget=pcl::PointXYZ
1>  ,            Scalar=float
1>          ]
1>          d:\clibrary\pcl1.8.0\pcl1.8.0x86\include\pcl-1.8\pcl\registration\registration.h(183) : 参见“pcl::Registration<PointSource,PointTarget,Scalar>::setInputCloud”的声明
1>          with
1>          [
1>              PointSource=pcl::PointXYZ
1>  ,            PointTarget=pcl::PointXYZ
1>  ,            Scalar=float
1>          ]

解决办法:

    //icp.setInputCloud(cloud_in);
    icp.setInputSource(cloud_in);

5.计算法线时使用OpenMP加速问题
正确的头文件应该是 #include

总结
在VS中编译开源库的工程,产生的问题可能五花八门,但其问题提示是比较清楚的,根据提示解决可以以不变应万变。实在解决不了,也可以问问度娘或google,正所谓内事不决问百度,外事不决问google

参考链接:
https://blog.csdn.net/wokaowokaowokao12345/article/details/51287011
https://blog.csdn.net/Linear_Luo/article/details/52658984

你可能感兴趣的:(PCL)