赞
踩
https://blog.csdn.net/Delsonyangx/article/details/128558689
大部分基础问题这篇就能解决.
遇到的编译问题主要有这几个难以解决:
1.opencv与flann冲突
- /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> >]’
- /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]’
- /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]’
- /usr/include/flann/algorithms/lsh_index.h:195:10: required from here
- /usr/include/flann/util/serialization.h:34:14: error: ‘class std::unordered_map<unsigned int, std::vector<unsigned int> >’ has no member named ‘serialize’
- 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
- make[1]: *** [CMakeFiles/Makefile2:545: LIO-SAM/CMakeFiles/lio_sam_mapOptmization.dir/all] Error 2
- make: *** [Makefile:141: all] Error 2
- Invoking "make -j16 -l16" failed
主要问题为编译顺序中的问题调整前面
- #include <opencv2/opencv.hpp>
- #include <opencv2/imgproc.hpp>
到include末尾就行了.
2.pcl问题
- /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&)'
- /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&)'
- /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&)'
- /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&)'
- /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&)'
- /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&)'
- /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&)'
- /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&)'
- /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&)'
- /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&)'
- /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&)'
- /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&)'
- collect2: error: ld returned 1 exit status
- 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
- make[1]: *** [CMakeFiles/Makefile2:633: LIO-SAM-DetailedNote/CMakeFiles/lio_sam_featureExtraction.dir/all] Error 2
这个就是链接问题,ros环境中有pcl1.10而我安装了pcl1.13,在链接时候出错误
因此我修改了cmake.txt来改变整个问题,但是不推荐这种方法,因为还要去修改msg的头文件问题,比较麻烦.附上修改后
- cmake_minimum_required(VERSION 2.8.3)
- project(lio_sam)
- #设置工程名称
- set(APP_NAME lio_sam)
-
- add_compile_options(-std=c++14)
- set(CMAKE_BUILD_TYPE Release)
-
- SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
-
-
- find_package(OpenMP REQUIRED)
- find_package(PCL 1.12 REQUIRED)
- find_package(OpenCV REQUIRED QUIET)
- find_package(GTSAM REQUIRED QUIET)
- find_package(Boost REQUIRED COMPONENTS timer)
- find_package(roscpp REQUIRED)
- find_package(catkin REQUIRED COMPONENTS tf)
-
-
- #工程头文件PROJECT_SOURCE_DIR工程根目录
- include_directories(
- include
- ${PROJECT_SOURCE_DIR}/..
- ${PROJECT_SOURCE_DIR}/include/lio_sam/
- /opt/ros/noetic/include/tf/
- /opt/ros/noetic/include/tf/LinearMath/
- src/include/
- )
- #第三方库头文件
- include_directories(
- ${PCL_INCLUDE_DIRS}
- ${OpenCV_INCLUDE_DIRS}
- ${GTSAM_INCLUDE_DIR}
- ${roscpp_INCLUDE_DIRS}
- ${roscpp_INCLUDE_DIRS}/tf/
- ${PROJECT_SOURCE_DIR}
- /usr/local/include/
- )
- #第三方库lib
- link_directories(
- include
- ${PCL_LIBRARIES}
- ${OpenCV_LIBRARY_DIRS}
- ${GTSAM_LIBRARY_DIRS}
- ${roscpp_LIBRARIES}
- )
-
- # Range Image Projection
- add_executable(${PROJECT_NAME}_imageProjection src/imageProjection.cpp)
- add_dependencies(${PROJECT_NAME}_imageProjection ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
- target_link_libraries(${PROJECT_NAME}_imageProjection ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${roscpp_LIBRARIES})
-
- # Feature Association
- add_executable(${PROJECT_NAME}_featureExtraction src/featureExtraction.cpp)
- add_dependencies(${PROJECT_NAME}_featureExtraction ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
- target_link_libraries(${PROJECT_NAME}_featureExtraction ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${roscpp_LIBRARIES})
-
- # Mapping Optimization
- add_executable(${PROJECT_NAME}_mapOptmization src/mapOptmization.cpp)
- add_dependencies(${PROJECT_NAME}_mapOptmization ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
- target_compile_options(${PROJECT_NAME}_mapOptmization PRIVATE ${OpenMP_CXX_FLAGS})
- target_link_libraries(${PROJECT_NAME}_mapOptmization Boost::timer ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${OpenMP_CXX_FLAGS} gtsam ${roscpp_LIBRARIES})
-
- # IMU Preintegration
- add_executable(${PROJECT_NAME}_imuPreintegration src/imuPreintegration.cpp)
- target_link_libraries(${PROJECT_NAME}_imuPreintegration Boost::timer ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} gtsam ${roscpp_LIBRARIES})
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。