PCL1.8.1编译问题及解决方法
PCL1.8.1版本
问题1:
#windows系统
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
#linux系统
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ILoYxavK-1664328634756)(C:\Users\Admin\AppData\Roaming\Typora\typora-user-images\image-20220928091204686.png)]
解决方法:
打开项目属性页>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));
}
重新编译即可解决问题。
问题2:
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.
解决方法:
打开项目属性页>C/C++>预处理器,添加:
_CRT_SECURE_NO_WARNINGS
问题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++>预处理器,添加:
PCL_NO_PRECOMPILE
问题4:
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”的声明
解决方法:
打开项目属性页>C/C++>预处理器,添加:
_CRT_SECURE_NO_WARNINGS
问题5:
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);
总结
在VS中编译开源库的工程,产生的问题可能五花八门,但其问题提示是比较清楚的,根据提示解决可以以不变应万变。实在解决不了,也可以问问度娘或google,正所谓内事不决问百度,外事不决问google。