轉載自:https://blog.csdn.net/wokaowokaowokao12345/article/details/51287011
在使用PCL1.8.0時可能出現各類編譯錯誤資訊,這篇博文就是将遇到的這些問題及解決方法進行彙總。
頭檔案中包含了:#include <pcl/sample_consensus/model_types.h> 就會出現問題
1、錯誤資訊pcl::SAC_SAMPLE_SIZE
今天使用PCL1.8編譯官方教程中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
解決方法1:
打開項目屬性頁>C/C++>正常>SDL檢查(設定為否)。 重新編譯,原先的錯誤資訊變成了警告。
解決方法2:
若上面的方法無法解決這個錯誤,可以打開頭檔案”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));
}
重新編譯即可解決問題。
2、錯誤資訊serialization.h(362):error C4996: 'fopen'
d:\clibrary\pcl1.8.0\pcl1.8.0x86\3rdparty\flann\include\flann\util\serialization.h(362): error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
解決方法1:
打開項目屬性頁>C/C++>預處理器,添加:
_CRT_SECURE_NO_WARNINGS
3、錯誤資訊ConditionalEuclideanClustering
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@[email protected]@pcl@@@pcl@@[email protected]@pcl@@[email protected]@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@[email protected]@pcl@@[email protected]@@pcl@@[email protected]@pcl@@@2@@Z)
1>E:\VisualStudio2013Project\PCLConsoleApplication\x64\Release\ConditionalEuclideanClustering.exe : fatal error LNK1120: 2 個無法解析的外部指令
在所有庫都配置的情況下,若出現上述問題。
解決方法1:
打開項目屬性頁>C/C++>預處理器,添加:
PCL_NO_PRECOMPILE
4、錯誤資訊serialization.h(362):error C4996: 'fopen'
F:\PCL1.8.0\3rdParty\FLANN\include\flann/util/serialization.h(362): error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> F:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\stdio.h(211) : 參見“fopen”的聲明
解決方法1:
打開項目屬性頁>C/C++>預處理器,添加:
_CRT_SECURE_NO_WARNINGS
5、錯誤資訊Registration
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> ]
解決方法1:
//icp.setInputCloud(cloud_in);
icp.setInputSource(cloud_in);
總結
在VS中編譯開源庫的工程,産生的問題可能五花八門,但其問題提示是比較清楚的,根據提示解決可以以不變應萬變。實在解決不了,也可以問問度娘或google,正所謂内事不決問百度,外事不決問google。