ORB_SLAM2编译出现问题(ros机器人开发实践p254)

建议按照这篇文章走一遍,应该可以编译成功

https://blog.csdn.net/u013019296/article/details/70052027

然后在: ./build_ros.sh 出现错误:
错误1

Building ROS nodes
mkdir: cannot create directory ‘build’: File exists
[rosbuild] Building package ORB_SLAM2
[rosbuild] Error from directory check: /opt/ros/kinetic/share/ros/core/rosbuild/bin/check_same_directories.py /home/nvidia/ORBSLAM2/ORB_SLAM2/Examples/ROS/ORB_SLAM2
1
Traceback (most recent call last):
File “/opt/ros/kinetic/share/ros/core/rosbuild/bin/check_same_directories.py”, line 46, in
raise Exception
Exception
CMake Error at /opt/ros/kinetic/share/ros/core/rosbuild/private.cmake:102 (message):
[rosbuild] rospack found package “ORB_SLAM2” at “”, but the current
directory is “/home/nvidia/ORBSLAM2/ORB_SLAM2/Examples/ROS/ORB_SLAM2”. You
should double-check your ROS_PACKAGE_PATH to ensure that packages are found
in the correct precedence order.
Call Stack (most recent call first):
/opt/ros/kinetic/share/ros/core/rosbuild/public.cmake:177 (_rosbuild_check_package_location)
CMakeLists.txt:4 (rosbuild_init)

– Configuring incomplete, errors occurred!
See also “/home/nvidia/ORBSLAM2/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/CMakeFiles/CMakeOutput.log”.
make: *** No targets specified and no makefile found. Stop.

解决办法:
sudo ln -s /home/<用户名>/ORB_SLAM2/Examples/ROS/ORB_SLAM2 /opt/ros/kinetic/share/ORB_SLAM2

然后继续 ./build_ros.sh
若提示build目录已经存在,那是因为你先前编译生成了build,但是是残缺的
解决:
/ORB_SLAM2/Examples/ROS/ORB_SLAM2 找到build删除重新编译
若再不能编译成功,参照错误2
参考:https://blog.csdn.net/weixin_40931266/article/details/81059763

错误2
/usr/bin/ld: CMakeFiles/RGBD.dir/src/ros_rgbd.cc.o: undefined reference to symbol ‘_ZN5boost6system15system_categoryEv’
/usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/RGBD.dir/build.make:218: recipe for target ‘…/RGBD’ failed
make[2]: * […/RGBD] Error 1
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/RGBD.dir/all’ failed
make[1]: * [CMakeFiles/RGBD.dir/all] Error 2
make[1]: * 正在等待未完成的任务….
/usr/bin/ld: CMakeFiles/Stereo.dir/src/ros_stereo.cc.o: undefined reference to symbol ‘_ZN5boost6system15system_categoryEv’
/usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/Stereo.dir/build.make:218: recipe for target ‘…/Stereo’ failed
make[2]: * […/Stereo] Error 1
CMakeFiles/Makefile2:104: recipe for target ‘CMakeFiles/Stereo.dir/all’ failed
make[1]: * [CMakeFiles/Stereo.dir/all] Error 2
Makefile:127: recipe for target ‘all’ failed
make: * [all] Error 2

参考:https://blog.csdn.net/sinat_38343378/article/details/78883919#commentsedit

解决办法:
1、直接在目录点放大镜搜索:
libboost_system.so
libboost_system.so.1.58.0
libboost_filesystem.so
libboost_filesystem.so.1.58.0
把这四个文件复制到ORB_SLAM2/lib

2、将ORBSLAM2/Examples/ROS/ORBSLAM2下的Cmakelists.txt中加入库目录,具体为
在set(LIBS
${OpenCV_LIBS}
${EIGEN3_LIBS}
${Pangolin_LIBRARIES}
${PROJECT_SOURCE_DIR}/…/…/…/Thirdparty/DBoW2/lib/libDBoW2.so
${PROJECT_SOURCE_DIR}/…/…/…/Thirdparty/g2o/lib/libg2o.so
P R O J E C T S O U R C E D I R / . . / . . / . . / l i b / l i b O R B S L A M 2. s o 之 后 加 入 {PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so 之后加入 PROJECTSOURCEDIR/../../../lib/libORBSLAM2.so{PROJECT_SOURCE_DIR}/…/…/…/lib/libboost_filesystem.so
${PROJECT_SOURCE_DIR}/…/…/…/lib/libboost_system.so

继续重新编译

最终/ORB_SLAM2/Examples/ROS/ORB_SLAM2 目录下有这些文件就说明编译成功了

在这里插入图片描述

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值