关于#ros系统中编译#的问题,如何解绝决?

想用一用之前看的论文里ros系统机械臂仿真模型,下载下来一直编译不通过,求大伙给看看到底问题出在哪了?
用的软件是vscode,系统是ubuntu18.04,编译用的是catkin_make
报错的主要代码(图中也可看出来):

img

img

In file included from /home/liuyihao/nbv3_ws/src/rvp_evaluation/src/evaluate_external_clusters_node.cpp:2:0:
/home/liuyihao/nbv3_ws/src/rvp_evaluation/include/rvp_evaluation/evaluator_external_clusters.h:18:36: error: ‘make_shared’ is not a member of ‘pcl’
   pcl::PointIndicesPtr inds = pcl::make_shared<pcl::PointIndices>();
                                    ^~~~~~~~~~~
/home/liuyihao/nbv3_ws/src/rvp_evaluation/include/rvp_evaluation/evaluator_external_clusters.h:18:36: note: suggested alternatives:
In file included from /usr/include/c++/7/memory:81:0,
                 from /usr/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/include/boost/shared_ptr.hpp:17,
                 from /opt/ros/melodic/include/ros/forwards.h:37,
                 from /opt/ros/melodic/include/ros/common.h:37,
                 from /opt/ros/melodic/include/ros/ros.h:43,
                 from /home/liuyihao/nbv3_ws/src/rvp_evaluation/src/evaluate_external_clusters_node.cpp:1:
/usr/include/c++/7/bits/shared_ptr.h:703:5: note:   ‘std::make_shared’
     make_shared(_Args&&... __args)
     ^~~~~~~~~~~
In file included from /usr/include/boost/smart_ptr/make_shared.hpp:17:0,
                 from /usr/include/boost/make_shared.hpp:14,
                 from /opt/ros/melodic/include/ros/forwards.h:38,
                 from /opt/ros/melodic/include/ros/common.h:37,
                 from /opt/ros/melodic/include/ros/ros.h:43,
                 from /home/liuyihao/nbv3_ws/src/rvp_evaluation/src/evaluate_external_clusters_node.cpp:1:
/usr/include/boost/smart_ptr/make_shared_array.hpp:41:1: note:   ‘boost::make_shared’
 make_shared(std::size_t size,
 ^~~~~~~~~~~
In file included from /usr/include/c++/7/memory:81:0,
                 from /usr/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/include/boost/shared_ptr.hpp:17,
                 from /opt/ros/melodic/include/ros/forwards.h:37,
                 from /opt/ros/melodic/include/ros/common.h:37,
                 from /opt/ros/melodic/include/ros/ros.h:43,
                 from /home/liuyihao/nbv3_ws/src/rvp_evaluation/src/evaluate_external_clusters_node.cpp:1:
/usr/include/c++/7/bits/shared_ptr.h:703:5: note:   ‘std::make_shared’
     make_shared(_Args&&... __args)
     ^~~~~~~~~~~

/usr/bin/ld: /usr/local/lib/libOpen3D_3rdparty_vtk_vtkFiltersModeling-9.1.a(vtkLoopSubdivisionFilter.cxx.o): undefined reference to symbol '_ZTI33vtkApproximatingSubdivisionFilter'
/usr/lib/x86_64-linux-gnu/libvtkFiltersGeneral-6.3.so.6.3.0: 无法添加符号: DSO missing from command line
collect2: error: ld returned 1 exit status
rvp_evaluation/CMakeFiles/evaluate_planner.dir/build.make:1321: recipe for target '/home/liuyihao/nbv3_ws/devel/lib/rvp_evaluation/evaluate_planner' failed
make[2]: *** [/home/liuyihao/nbv3_ws/devel/lib/rvp_evaluation/evaluate_planner] Error 1
CMakeFiles/Makefile2:6456: recipe for target 'rvp_evaluation/CMakeFiles/evaluate_planner.dir/all' failed
make[1]: *** [rvp_evaluation/CMakeFiles/evaluate_planner.dir/all] Error 2
/usr/bin/ld: /usr/local/lib/libOpen3D_3rdparty_vtk_vtkFiltersModeling-9.1.a(vtkLoopSubdivisionFilter.cxx.o): undefined reference to symbol '_ZTI33vtkApproximatingSubdivisionFilter'
/usr/lib/x86_64-linux-gnu/libvtkFiltersGeneral-6.3.so.6.3.0: 无法添加符号: DSO missing from command line
collect2: error: ld returned 1 exit status
rvp_evaluation/CMakeFiles/evaluate_rosbag_no_gt.dir/build.make:1321: recipe for target '/home/liuyihao/nbv3_ws/devel/lib/rvp_evaluation/evaluate_rosbag_no_gt' failed
make[2]: *** [/home/liuyihao/nbv3_ws/devel/lib/rvp_evaluation/evaluate_rosbag_no_gt] Error 1
CMakeFiles/Makefile2:6588: recipe for target 'rvp_evaluation/CMakeFiles/evaluate_rosbag_no_gt.dir/all' failed
make[1]: *** [rvp_evaluation/CMakeFiles/evaluate_rosbag_no_gt.dir/all] Error 2
/usr/bin/ld: /usr/local/lib/libOpen3D_3rdparty_vtk_vtkFiltersModeling-9.1.a(vtkLoopSubdivisionFilter.cxx.o): undefined reference to symbol '_ZTI33vtkApproximatingSubdivisionFilter'
/usr/lib/x86_64-linux-gnu/libvtkFiltersGeneral-6.3.so.6.3.0: 无法添加符号: DSO missing from command line
collect2: error: ld returned 1 exit status
rvp_evaluation/CMakeFiles/evaluate_saved_tree.dir/build.make:1321: recipe for target '/home/liuyihao/nbv3_ws/devel/lib/rvp_evaluation/evaluate_saved_tree' failed
make[2]: *** [/home/liuyihao/nbv3_ws/devel/lib/rvp_evaluation/evaluate_saved_tree] Error 1
CMakeFiles/Makefile2:6720: recipe for target 'rvp_evaluation/CMakeFiles/evaluate_saved_tree.dir/all' failed
make[1]: *** [rvp_evaluation/CMakeFiles/evaluate_saved_tree.dir/all] Error 2
Makefile:145: recipe for target 'all' failed
make: *** [all] Error 2



error:‘make_shared' is not a member of 'pcl'是关键

感觉还是vtk相关的库没有配置好,导致链接失败。

该回答引用于gpt与OKX安生共同编写:
  • 该回答引用于gpt与OKX安生共同编写:

根据你提供的错误信息,可以看到有两个主要的问题:

  1. 在使用 PCL 库时,pcl::make_shared 函数出错。

这个问题可能是由于 PCL 版本问题导致的,pcl::make_shared 函数在旧版本中不一定支持。可以尝试升级 PCL 库,或者修改代码,将 pcl::make_shared 替换为 std::make_sharedboost::make_shared

  1. 在链接时缺少依赖库。

这个问题可能是由于编译命令中未正确指定需要链接的库导致的。可以检查编译命令,在链接时指定缺少的库即可解决该问题。

具体来说,可以在 CMakeLists.txt 文件中添加以下语句,以链接 PCL 和 VTK 库:

find_package(PCL REQUIRED)
find_package(VTK REQUIRED)

include_directories(${PCL_INCLUDE_DIRS} ${VTK_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS} ${VTK_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

target_link_libraries(your_executable_name ${PCL_LIBRARIES} ${VTK_LIBRARIES})

其中,将 your_executable_name 替换为实际的可执行文件名。

如果以上方法无法解决问题,建议参考相关论坛或官方文档,查找更详细的解决方案。

  • 如有用的话,还望采纳哦~

以下答案由GPT-3.5大模型与博主波罗歌共同编写:
根据报错信息,在编译时碰到了两个问题:

  1. 在使用pcl::make_shared()函数时,出现了找不到此函数的错误。可能是因为pcl库版本不同,建议查看一下当前pcl的版本,并查看对应版本的文档中是否有pcl::make_shared()函数的说明。如果没有,可以尝试使用std::make_shared()函数替代。

  2. 在链接期间,出现了找不到vtkApproximatingSubdivisionFilter符号的错误。这可能意味着链接时缺少了某个库文件,建议查看一下工程中是否存在此库文件,并将其添加到链接器的搜索路径中。

参考代码:

// 使用std::make_shared()代替pcl::make_shared()
std::shared_ptr<pcl::PointIndices> inds = std::make_shared<pcl::PointIndices>();

// 将链接器需要的库文件添加到链接器搜索路径中
// -lOpen3D_3rdparty_vtk_vtkFiltersModeling-9.1:链接vtkFiltersModeling库
CMAKE_CXX_FLAGS="-L/usr/local/lib -lOpen3D_3rdparty_vtk_vtkFiltersModeling-9.1"

如果我的回答解决了您的问题,请采纳!

问题分析:
根据报错信息,可以看出主要有两个问题:
1.‘make_shared’ is not a member of ‘pcl’
2.undefined reference to symbol '_ZTI33vtkApproximatingSubdivisionFilter'
第一个问题是在使用pcl库时出现的,可能是因为pcl库版本不兼容或者缺少相关依赖库导致的。第二个问题是在链接时出现的,可能是因为缺少相关库或者链接顺序不正确导致的。
解决方案:
1.针对第一个问题,可以尝试升级或者降级pcl库版本,或者安装缺少的依赖库。具体可以参考pcl官方文档或者在网上搜索相关解决方案。
2.针对第二个问题,可以尝试在CMakeLists.txt文件中添加相关库的链接,或者调整链接顺序。具体可以参考CMake官方文档或者在网上搜索相关解决方案。
总结:
在编译过程中出现问题是很常见的,需要耐心分析和解决。针对不同的问题,需要采取不同的解决方案。同时,也需要注意库版本兼容性和链接顺序等问题。