‘pcl::visualization::CloudViewer::showCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXY...’未定义的引用

问题:

ubuntu18编译ubuntu16的ros功能包时,pcl 1.8报错:

CMakeFiles/velodyne_imu_gps.dir/src/velodyne_imu_gps.cpp.o:在函数‘chatterCallback(boost::shared_ptr<sensor_msgs::PointCloud2_<std::allocator<void> > const> const&, boost::shared_ptr<sensor_msgs::Imu_<std::allocator<void> > const> const&)’中:
velodyne_imu_gps.cpp:(.text+0x16a8):对‘pcl::visualization::CloudViewer::showCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)’未定义的引用
velodyne_imu_gps.cpp:(.text+0x17ba):对‘pcl::visualization::CloudViewer::showCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)’未定义的引用
velodyne_imu_gps.cpp:(.text+0x18bc):对‘pcl::visualization::CloudViewer::showCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)’未定义的引用
velodyne_imu_gps.cpp:(.text+0x19be):对‘pcl::visualization::CloudViewer::showCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)’未定义的引用
velodyne_imu_gps.cpp:(.text+0x1ac0):对‘pcl::visualization::CloudViewer::showCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)’未定义的引用
CMakeFiles/velodyne_imu_gps.dir/src/velodyne_imu_gps.cpp.o:velodyne_imu_gps.cpp:(.text+0x1bf0): 跟着更多未定义的参考到 pcl::visualization::CloudViewer::showCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
CMakeFiles/velodyne_imu_gps.dir/src/velodyne_imu_gps.cpp.o:在函数‘__static_initialization_and_destruction_0(int, int)’中:
velodyne_imu_gps.cpp:(.text+0x2b2b):对‘pcl::visualization::CloudViewer::CloudViewer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)’未定义的引用
velodyne_imu_gps.cpp:(.text+0x2b58):对‘pcl::visualization::CloudViewer::~CloudViewer()’未定义的引用
collect2: error: ld returned 1 exit status
camera-laser-calibration-master/camLaserCalib/CMakeFiles/velodyne_imu_gps.dir/build.make:319: recipe for target '/home/xx/catkin_ws/devel/lib/cam_laser_calib/velodyne_imu_gps' failed
make[2]: *** [/home/xx/catkin_ws/devel/lib/cam_laser_calib/velodyne_imu_gps] Error 1
CMakeFiles/Makefile2:3694: recipe for target 'camera-laser-calibration-master/camLaserCalib/CMakeFiles/velodyne_imu_gps.dir/all' failed
make[1]: *** [camera-laser-calibration-master/camLaserCalib/CMakeFiles/velodyne_imu_gps.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....
[100%] Built target cam_laser_calib_node
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

解决:

打开cmakelist.txt
在用到CloudViewer::showCloud文件的velodyne_imu_gps.cpp的位置,加上${PCL_LIBRARIES}
如:

add_executable(velodyne_imu_gps src/velodyne_imu_gps.cpp)
target_link_libraries(velodyne_imu_gps  ${catkin_LIBRARIES}  ${PCL_LIBRARIES})

其他

以下内容非必须的改动
当用到pcl时,在编写cmakelist时:

find_package(PCL REQUIRED)
set(PCL_INCLUDE_DIRS /usr/include/pcl-1.8)  #指定pcl1.8路径
add_definitions(${PCL_DEFINITIONS})
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值