当前位置:   article > 正文

20.04ubantu 编译lio_sam问题解决_error: 鈥榗lass std::unordered_map

error: 鈥榗lass std::unordered_map >

https://blog.csdn.net/Delsonyangx/article/details/128558689

大部分基础问题这篇就能解决.

遇到的编译问题主要有这几个难以解决:
1.opencv与flann冲突

  1. /usr/include/flann/util/serialization.h:56:33: required from ‘static void flann::serialization::Serializer<T>::save(OutputArchive&, const T&) [with OutputArchive = flann::serialization::SaveArchive; T = flann::LshIndex<flann::L2_Simple<float> >]’
  2. /usr/include/flann/util/serialization.h:316:28: required from ‘Archive& flann::serialization::OutputArchive<Archive>::operator&(const T&) [with T = flann::LshIndex<flann::L2_Simple<float> >; Archive = flann::serialization::SaveArchive]’
  3. /usr/include/flann/algorithms/lsh_index.h:198:9: required from ‘void flann::LshIndex<Distance>::saveIndex(FILE*) [with Distance = flann::L2_Simple<float>; FILE = _IO_FILE]’
  4. /usr/include/flann/algorithms/lsh_index.h:195:10: required from here
  5. /usr/include/flann/util/serialization.h:34:14: error: ‘class std::unordered_map<unsigned int, std::vector<unsigned int> >’ has no member named ‘serialize’
  6. make[2]: *** [LIO-SAM/CMakeFiles/lio_sam_mapOptmization.dir/build.make:63: LIO-SAM/CMakeFiles/lio_sam_mapOptmization.dir/src/mapOptmization.cpp.o] Error 1
  7. make[1]: *** [CMakeFiles/Makefile2:545: LIO-SAM/CMakeFiles/lio_sam_mapOptmization.dir/all] Error 2
  8. make: *** [Makefile:141: all] Error 2
  9. Invoking "make -j16 -l16" failed

主要问题为编译顺序中的问题调整前面

  1. #include <opencv2/opencv.hpp>
  2. #include <opencv2/imgproc.hpp>

到include末尾就行了.

2.pcl问题

  1. /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_9PointXYZIEEE[_ZTVN3pcl7PCLBaseINS_9PointXYZIEEE]+0x20): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setInputCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZI> const> const&)'
  2. /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_9PointXYZIEEE[_ZTVN3pcl7PCLBaseINS_9PointXYZIEEE]+0x28): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > > const&)'
  3. /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_9PointXYZIEEE[_ZTVN3pcl7PCLBaseINS_9PointXYZIEEE]+0x30): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
  4. /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_9PointXYZIEEE[_ZTVN3pcl7PCLBaseINS_9PointXYZIEEE]+0x38): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)'
  5. /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_9PointXYZIEEE[_ZTVN3pcl6FilterINS_9PointXYZIEEE]+0x20): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setInputCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZI> const> const&)'
  6. /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_9PointXYZIEEE[_ZTVN3pcl6FilterINS_9PointXYZIEEE]+0x28): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > > const&)'
  7. /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_9PointXYZIEEE[_ZTVN3pcl6FilterINS_9PointXYZIEEE]+0x30): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
  8. /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_9PointXYZIEEE[_ZTVN3pcl6FilterINS_9PointXYZIEEE]+0x38): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)'
  9. /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl9VoxelGridINS_9PointXYZIEEE[_ZTVN3pcl9VoxelGridINS_9PointXYZIEEE]+0x20): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setInputCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZI> const> const&)'
  10. /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl9VoxelGridINS_9PointXYZIEEE[_ZTVN3pcl9VoxelGridINS_9PointXYZIEEE]+0x28): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > > const&)'
  11. /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl9VoxelGridINS_9PointXYZIEEE[_ZTVN3pcl9VoxelGridINS_9PointXYZIEEE]+0x30): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
  12. /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl9VoxelGridINS_9PointXYZIEEE[_ZTVN3pcl9VoxelGridINS_9PointXYZIEEE]+0x38): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)'
  13. collect2: error: ld returned 1 exit status
  14. make[2]: *** [LIO-SAM-DetailedNote/CMakeFiles/lio_sam_featureExtraction.dir/build.make:396: /home/project/LIO-SAM/devel/lib/lio_sam/lio_sam_featureExtraction] Error 1
  15. make[1]: *** [CMakeFiles/Makefile2:633: LIO-SAM-DetailedNote/CMakeFiles/lio_sam_featureExtraction.dir/all] Error 2

这个就是链接问题,ros环境中有pcl1.10而我安装了pcl1.13,在链接时候出错误

因此我修改了cmake.txt来改变整个问题,但是不推荐这种方法,因为还要去修改msg的头文件问题,比较麻烦.附上修改后

  1. cmake_minimum_required(VERSION 2.8.3)
  2. project(lio_sam)
  3. #设置工程名称
  4. set(APP_NAME lio_sam)
  5. add_compile_options(-std=c++14)
  6. set(CMAKE_BUILD_TYPE Release)
  7. SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
  8. find_package(OpenMP REQUIRED)
  9. find_package(PCL 1.12 REQUIRED)
  10. find_package(OpenCV REQUIRED QUIET)
  11. find_package(GTSAM REQUIRED QUIET)
  12. find_package(Boost REQUIRED COMPONENTS timer)
  13. find_package(roscpp REQUIRED)
  14. find_package(catkin REQUIRED COMPONENTS tf)
  15. #工程头文件PROJECT_SOURCE_DIR工程根目录
  16. include_directories(
  17. include
  18. ${PROJECT_SOURCE_DIR}/..
  19. ${PROJECT_SOURCE_DIR}/include/lio_sam/
  20. /opt/ros/noetic/include/tf/
  21. /opt/ros/noetic/include/tf/LinearMath/
  22. src/include/
  23. )
  24. #第三方库头文件
  25. include_directories(
  26. ${PCL_INCLUDE_DIRS}
  27. ${OpenCV_INCLUDE_DIRS}
  28. ${GTSAM_INCLUDE_DIR}
  29. ${roscpp_INCLUDE_DIRS}
  30. ${roscpp_INCLUDE_DIRS}/tf/
  31. ${PROJECT_SOURCE_DIR}
  32. /usr/local/include/
  33. )
  34. #第三方库lib
  35. link_directories(
  36. include
  37. ${PCL_LIBRARIES}
  38. ${OpenCV_LIBRARY_DIRS}
  39. ${GTSAM_LIBRARY_DIRS}
  40. ${roscpp_LIBRARIES}
  41. )
  42. # Range Image Projection
  43. add_executable(${PROJECT_NAME}_imageProjection src/imageProjection.cpp)
  44. add_dependencies(${PROJECT_NAME}_imageProjection ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
  45. target_link_libraries(${PROJECT_NAME}_imageProjection ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${roscpp_LIBRARIES})
  46. # Feature Association
  47. add_executable(${PROJECT_NAME}_featureExtraction src/featureExtraction.cpp)
  48. add_dependencies(${PROJECT_NAME}_featureExtraction ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
  49. target_link_libraries(${PROJECT_NAME}_featureExtraction ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${roscpp_LIBRARIES})
  50. # Mapping Optimization
  51. add_executable(${PROJECT_NAME}_mapOptmization src/mapOptmization.cpp)
  52. add_dependencies(${PROJECT_NAME}_mapOptmization ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
  53. target_compile_options(${PROJECT_NAME}_mapOptmization PRIVATE ${OpenMP_CXX_FLAGS})
  54. target_link_libraries(${PROJECT_NAME}_mapOptmization Boost::timer ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${OpenMP_CXX_FLAGS} gtsam ${roscpp_LIBRARIES})
  55. # IMU Preintegration
  56. add_executable(${PROJECT_NAME}_imuPreintegration src/imuPreintegration.cpp)
  57. target_link_libraries(${PROJECT_NAME}_imuPreintegration Boost::timer ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} gtsam ${roscpp_LIBRARIES})

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/481413
推荐阅读
相关标签
  

闽ICP备14008679号