vickyTwan 2023-02-16 09:32 采纳率: 60%
浏览 17
已结题

ros点云地面分割代码报错,如何解决?(语言-c++|操作系统-ubuntu)

跑adam博主的点云地面分割代码 功能包编译最后一步总是跳这个错误是为什么?https://adamshan.blog.csdn.net/article/details/82901295
[100%] Linking CXX executable /home/vickytwan/pcl_ws/devel/lib/pcl_test/pcl_test_node
/usr/bin/ld: CMakeFiles/pcl_test_node.dir/src/pcl_test_core.cpp.o: in function PclTestCore::point_cb(boost::shared_ptr<sensor_msgs::PointCloud2_<std::allocator<void> > const> const&)': pcl_test_core.cpp:(.text+0x416): undefined reference to pcl::PCLBasepcl::PointXYZI::setInputCloud(std::shared_ptr<pcl::PointCloudpcl::PointXYZI const> const&)'
/usr/bin/ld: CMakeFiles/pcl_test_node.dir/src/pcl_test_core.cpp.o:(.data.rel.ro._ZTVN3pcl9VoxelGridINS_9PointXYZIEEE[_ZTVN3pcl9VoxelGridINS_9PointXYZIEEE]+0x20): undefined reference to pcl::PCLBase<pcl::PointXYZI>::setInputCloud(std::shared_ptr<pcl::PointCloud<pcl::PointXYZI> const> const&)' /usr/bin/ld: CMakeFiles/pcl_test_node.dir/src/pcl_test_core.cpp.o:(.data.rel.ro._ZTVN3pcl9VoxelGridINS_9PointXYZIEEE[_ZTVN3pcl9VoxelGridINS_9PointXYZIEEE]+0x28): undefined reference to pcl::PCLBasepcl::PointXYZI::setIndices(std::shared_ptr<std::vector<int, std::allocator > > const&)'
/usr/bin/ld: CMakeFiles/pcl_test_node.dir/src/pcl_test_core.cpp.o:(.data.rel.ro._ZTVN3pcl9VoxelGridINS_9PointXYZIEEE[_ZTVN3pcl9VoxelGridINS_9PointXYZIEEE]+0x30): undefined reference to pcl::PCLBase<pcl::PointXYZI>::setIndices(std::shared_ptr<std::vector<int, std::allocator<int> > const> const&)' /usr/bin/ld: CMakeFiles/pcl_test_node.dir/src/pcl_test_core.cpp.o:(.data.rel.ro._ZTVN3pcl9VoxelGridINS_9PointXYZIEEE[_ZTVN3pcl9VoxelGridINS_9PointXYZIEEE]+0x38): undefined reference to pcl::PCLBasepcl::PointXYZI::setIndices(std::shared_ptr<pcl::PointIndices const> const&)'
/usr/bin/ld: CMakeFiles/pcl_test_node.dir/src/pcl_test_core.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_9PointXYZIEEE[_ZTVN3pcl6FilterINS_9PointXYZIEEE]+0x20): undefined reference to pcl::PCLBase<pcl::PointXYZI>::setInputCloud(std::shared_ptr<pcl::PointCloud<pcl::PointXYZI> const> const&)' /usr/bin/ld: CMakeFiles/pcl_test_node.dir/src/pcl_test_core.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_9PointXYZIEEE[_ZTVN3pcl6FilterINS_9PointXYZIEEE]+0x28): undefined reference to pcl::PCLBasepcl::PointXYZI::setIndices(std::shared_ptr<std::vector<int, std::allocator > > const&)'
/usr/bin/ld: CMakeFiles/pcl_test_node.dir/src/pcl_test_core.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_9PointXYZIEEE[_ZTVN3pcl6FilterINS_9PointXYZIEEE]+0x30): undefined reference to pcl::PCLBase<pcl::PointXYZI>::setIndices(std::shared_ptr<std::vector<int, std::allocator<int> > const> const&)' /usr/bin/ld: CMakeFiles/pcl_test_node.dir/src/pcl_test_core.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_9PointXYZIEEE[_ZTVN3pcl6FilterINS_9PointXYZIEEE]+0x38): undefined reference to pcl::PCLBasepcl::PointXYZI::setIndices(std::shared_ptr<pcl::PointIndices const> const&)'
/usr/bin/ld: CMakeFiles/pcl_test_node.dir/src/pcl_test_core.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_9PointXYZIEEE[_ZTVN3pcl7PCLBaseINS_9PointXYZIEEE]+0x20): undefined reference to pcl::PCLBase<pcl::PointXYZI>::setInputCloud(std::shared_ptr<pcl::PointCloud<pcl::PointXYZI> const> const&)' /usr/bin/ld: CMakeFiles/pcl_test_node.dir/src/pcl_test_core.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_9PointXYZIEEE[_ZTVN3pcl7PCLBaseINS_9PointXYZIEEE]+0x28): undefined reference to pcl::PCLBasepcl::PointXYZI::setIndices(std::shared_ptr<std::vector<int, std::allocator > > const&)'
/usr/bin/ld: CMakeFiles/pcl_test_node.dir/src/pcl_test_core.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_9PointXYZIEEE[_ZTVN3pcl7PCLBaseINS_9PointXYZIEEE]+0x30): undefined reference to pcl::PCLBase<pcl::PointXYZI>::setIndices(std::shared_ptr<std::vector<int, std::allocator<int> > const> const&)' /usr/bin/ld: CMakeFiles/pcl_test_node.dir/src/pcl_test_core.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_9PointXYZIEEE[_ZTVN3pcl7PCLBaseINS_9PointXYZIEEE]+0x38): undefined reference to pcl::PCLBasepcl::PointXYZI::setIndices(std::shared_ptr<pcl::PointIndices const> const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [pcl_test/CMakeFiles/pcl_test_node.dir/build.make:215:/home/vickytwan/pcl_ws/devel/lib/pcl_test/pcl_test_node] 错误 1
make[1]: *** [CMakeFiles/Makefile2:482:pcl_test/CMakeFiles/pcl_test_node.dir/all] 错误 2
make: *** [Makefile:141:all] 错误 2
Invoking "make -j2 -l2" failed

  • 写回答

2条回答 默认 最新

  • 量化研究所 2023-02-16 09:36
    关注

    这个错误是由于链接错误导致的。当您尝试构建一个程序时,编译器将从多个源文件中提取目标代码并将其链接在一起以创建最终的可执行文件。这个错误发生在链接时,因为编译器找不到所需的目标代码。

    在您的情况下,错误消息指出了一些在链接时找不到的符号,这些符号似乎与PCL库的一些方法有关。可能是您忘记链接某个库,或者库路径不正确,或者库版本不正确。您可以按照以下步骤尝试解决此问题:

    确保已经正确地安装了 PCL 库,包括开发文件(包括头文件和库文件)。
    确认在 CMakeLists.txt 文件中,已经正确地设置了 PCL 库的路径和包含路径,并在 target_link_libraries()函数中包含所需的库。
    检查您的代码,确保您正确地包含了必需的头文件,并在代码中正确地使用了PCL库中的方法。
    如果您仍然无法解决问题,请提供更多细节和您的代码。
    望采纳。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 2月24日
  • 已采纳回答 2月16日
  • 创建了问题 2月16日

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分