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檢查(設置爲否)
在這裏插入圖片描述
若上面的方案無法解決這個錯誤,可以打開頭文件“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<struct pcl::PointXYZINormal>::segment(class std::vector<struct pcl::PointIndices,class std::allocator<struct pcl::PointIndices> > &)" (?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<struct pcl::PointXYZI,struct pcl::PointXYZINormal>::computeFeature(class pcl::PointCloud<struct pcl::PointXYZINormal> &)" (?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<PointSource,PointTarget,Scalar>::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 <pcl/features/impl/normal_3d_omp.hpp>

總結
在VS中編譯開源庫的工程,產生的問題可能五花八門,但其問題提示是比較清楚的,根據提示解決可以以不變應萬變。實在解決不了,也可以問問度娘或google,正所謂內事不決問百度,外事不決問google

參考鏈接:
https://blog.csdn.net/wokaowokaowokao12345/article/details/51287011
https://blog.csdn.net/Linear_Luo/article/details/52658984

發佈了18 篇原創文章 · 獲贊 7 · 訪問量 9326
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章