环境
Ubuntu 14.04 +ROS Indigo +PCL 1.8
报错日志
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::PCLBase()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::deinitCompute()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::visualization::CloudViewer::showCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGBA> const> const&, std::string const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::visualization::CloudViewer::~CloudViewer()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::visualization::CloudViewer::CloudViewer(std::string const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > > const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::VoxelGrid<pcl::PointXYZRGBA>::applyFilter(pcl::PointCloud<pcl::PointXYZRGBA>&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::initCompute()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setInputCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGBA> const> const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [../Examples/Stereo/stereo_kitti] Error 1
make[1]: *** [CMakeFiles/stereo_kitti.dir/all] Error 2
[100%] Linking CXX executable ../Examples/Stereo/stereo_euroc
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::PCLBase()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::deinitCompute()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::visualization::CloudViewer::showCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGBA> const> const&, std::string const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::visualization::CloudViewer::~CloudViewer()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::visualization::CloudViewer::CloudViewer(std::string const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > > const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::VoxelGrid<pcl::PointXYZRGBA>::applyFilter(pcl::PointCloud<pcl::PointXYZRGBA>&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::initCompute()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setInputCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGBA> const> const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [../Examples/RGB-D/rgbd_tum] Error 1
make[1]: *** [CMakeFiles/rgbd_tum.dir/all] Error 2
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::PCLBase()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::deinitCompute()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::visualization::CloudViewer::showCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGBA> const> const&, std::string const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::visualization::CloudViewer::~CloudViewer()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::visualization::CloudViewer::CloudViewer(std::string const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > > const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::VoxelGrid<pcl::PointXYZRGBA>::applyFilter(pcl::PointCloud<pcl::PointXYZRGBA>&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::initCompute()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setInputCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGBA> const> const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [../Examples/Monocular/mono_tum] Error 1
make[1]: *** [CMakeFiles/mono_tum.dir/all] Error 2
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::PCLBase()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::deinitCompute()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::visualization::CloudViewer::showCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGBA> const> const&, std::string const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::visualization::CloudViewer::~CloudViewer()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::visualization::CloudViewer::CloudViewer(std::string const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > > const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::VoxelGrid<pcl::PointXYZRGBA>::applyFilter(pcl::PointCloud<pcl::PointXYZRGBA>&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::initCompute()'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setInputCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGBA> const> const&)'
../lib/libORB_SLAM2.so: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [../Examples/Stereo/stereo_euroc] Error 1
make[1]: *** [CMakeFiles/stereo_euroc.dir/all] Error 2
make: *** [all] Error 2
解决
CMakeLists.txt
中加入以下内容:
find_package (PCL 1.8 REQUIRED)
set(PCL_INCLUDE_DIRS /usr/local/include/pcl-1.8) #指定pcl1.8路径
add_definitions(${PCL_DEFINITIONS})
include_directories( ... ${PCL_INCLUDE_DIRS})
target_link_libraries( ... ${PCL_LIBRARIES})