对‘pcl::KdTreeFLANN<pcl::PointXYZ, flann::L2_Simple<float> >::KdTreeFLANN(bool)’未定义的引用的解决方法

最近在学习PCL点云库相关内容,参考https://www.cnblogs.com/li-yao7758258/p/6437440.html的kdtree代码,发现出现如下bug:

kdtree.cpp:(.text+0x223):对‘pcl::KdTreeFLANN<pcl::PointXYZ,
flann::L2_Simple >::KdTreeFLANN(bool)’未定义在这里插入代码片的引用
kdtree.cpp:(.text+0x275):对‘pcl::KdTreeFLANN<pcl::PointXYZ,
flann::L2_Simple >::setInputCloud(boost::shared_ptr<pcl::PointCloudpcl::PointXYZ const> const&, boost::shared_ptr<std::vector<int, std::allocator
const> const&)’未定义的引用 kdtree.cpp:(.text+0x4a9):对‘pcl::KdTreeFLANN<pcl::PointXYZ,
flann::L2_Simple >::nearestKSearch(pcl::PointXYZ const&, int,
std::vector<int, std::allocator >&, std::vector<float,
std::allocator >&) const’未定义的引用
kdtree.cpp:(.text+0x7cb):对‘pcl::KdTreeFLANN<pcl::PointXYZ,
flann::L2_Simple >::radiusSearch(pcl::PointXYZ const&, double,
std::vector<int, std::allocator >&, std::vector<float,
std::allocator >&, unsigned int) const’未定义的引用
CMakeFiles/kdtree.dir/kdtree.cpp.o:在函数‘pcl::KdTreeFLANN<pcl::PointXYZ,
flann::L2_Simple >::~KdTreeFLANN()’中:
kdtree.cpp:(.text._ZN3pcl11KdTreeFLANNINS_8PointXYZEN5flann9L2_SimpleIfEEED2Ev[_ZN3pcl11KdTreeFLANNINS_8PointXYZEN5flann9L2_SimpleIfEEED5Ev]+0x27):对‘pcl::KdTreeFLANN<pcl::PointXYZ,
flann::L2_Simple >::cleanup()’未定义的引用
CMakeFiles/kdtree.dir/kdtree.cpp.o:(.data.rel.ro._ZTVN3pcl11KdTreeFLANNINS_8PointXYZEN5flann9L2_SimpleIfEEEE[_ZTVN3pcl11KdTreeFLANNINS_8PointXYZEN5flann9L2_SimpleIfEEEE]+0x10):对‘pcl::KdTreeFLANN<pcl::PointXYZ,
flann::L2_Simple
::setInputCloud(boost::shared_ptr<pcl::PointCloudpcl::PointXYZ const> const&, boost::shared_ptr<std::vector<int, std::allocator
const> const&)’未定义的引用 CMakeFiles/kdtree.dir/kdtree.cpp.o:(.data.rel.ro._ZTVN3pcl11KdTreeFLANNINS_8PointXYZEN5flann9L2_SimpleIfEEEE[_ZTVN3pcl11KdTreeFLANNINS_8PointXYZEN5flann9L2_SimpleIfEEEE]+0x28):对‘pcl::KdTreeFLANN<pcl::PointXYZ,
flann::L2_Simple >::nearestKSearch(pcl::PointXYZ const&, int,
std::vector<int, std::allocator >&, std::vector<float,
std::allocator >&) const’未定义的引用
CMakeFiles/kdtree.dir/kdtree.cpp.o:(.data.rel.ro._ZTVN3pcl11KdTreeFLANNINS_8PointXYZEN5flann9L2_SimpleIfEEEE[_ZTVN3pcl11KdTreeFLANNINS_8PointXYZEN5flann9L2_SimpleIfEEEE]+0x40):对‘pcl::KdTreeFLANN<pcl::PointXYZ,
flann::L2_Simple >::radiusSearch(pcl::PointXYZ const&, double,
std::vector<int, std::allocator >&, std::vector<float,
std::allocator >&, unsigned int) const’未定义的引用
CMakeFiles/kdtree.dir/kdtree.cpp.o:(.data.rel.ro._ZTVN3pcl11KdTreeFLANNINS_8PointXYZEN5flann9L2_SimpleIfEEEE[_ZTVN3pcl11KdTreeFLANNINS_8PointXYZEN5flann9L2_SimpleIfEEEE]+0x58):对‘pcl::KdTreeFLANN<pcl::PointXYZ,
flann::L2_Simple >::setEpsilon(float)’未定义的引用 collect2: error:
ld returned 1 exit status CMakeFiles/kdtree.dir/build.make:310: recipe
for target ‘kdtree’ failed make[2]: *** [kdtree] Error 1
CMakeFiles/Makefile2:104: recipe for target
‘CMakeFiles/kdtree.dir/all’ failed make[1]: ***
[CMakeFiles/kdtree.dir/all] Error 2 Makefile:83: recipe for target
‘all’ failed make: *** [all] Error 2

解决方法
找到kdtree_flann.h文件,加入#define PCL_NO_PRECOMPILE
如图所示
在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Thinkin9/article/details/121548943