반응형
# Problem
When I was build LIO SLAM, I got a following Error
Errors << aloam_velodyne:make /home/sjchoi/catkin_ws/logs/aloam_velodyne/build.make.016.log
/usr/bin/ld: cannot find -lBoost::serialization
/usr/bin/ld: cannot find -lBoost::thread
/usr/bin/ld: cannot find -lBoost::timer
/usr/bin/ld: cannot find -lBoost::chrono
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/alaserPGO.dir/build.make:299: /home/sjchoi/catkin_ws/devel/.private/aloam_velodyne/lib/aloam_velodyne/alaserPGO] Error 1
# Solution
First of all, install Boost Library. then, you need to modify CMakeLists.txt.
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost COMPONENTS serialization timer thread chrono)
include_directories(
include
${catkin_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
${CERES_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
${GTSAM_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
)
...
target_link_libraries(alaserPGO
${catkin_LIBRARIES} ${PCL_LIBRARIES} ${CERES_LIBRARIES}
${OpenMP_CXX_FLAGS} ${Boost_INCLUDE_DIRS}
gtsam
)
If you find an error that you can't find Boost::serialization in the future, you can add the following code.
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost COMPONENTS serialization timer thread chrono)
include_directories(
include
${GTSAM_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
)
error like: CMake Error at /usr/local/lib/cmake/GTSAM/GTSAM-exports.cmake:68 (add_library): The link interface of target "gtsam" contains: Boost::serialization
# Reference
- [Blog]/usr/bin/ld: cannot find -lBoost::serialization: https://blog.csdn.net/weixin_42650491/article/details/119818539
- [StackOverFlow] How do you add Boost libraries in CMakeLists.txt?: https://stackoverflow.com/questions/6646405/how-do-you-add-boost-libraries-in-cmakelists-txt
반응형