环境变量未正确设置,使用以下命令设置(只在当前终端有效)
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/你的用户名/catkin_ws/src/ORB_SLAM2/Examples/ROS
验证环境变量正确命令:
echo $ROS_PACKAGE_PATH
正确设置会输出以下信息(路径以我的为例):
/opt/ros/melodic/share:/home/lzj/catkin_ws/src/ORB_SLAM2/Examples/ROS
2、usleep未声明
error: ‘usleep’ was not declared in this scope usleep(5000);
在报错文件上添加头文件#include<unistd.h>
3、执行./build_ros.sh命令报错
Building ROS nodes
mkdir: 无法创建目录"build": 文件已存在
CMake Deprecation Warning at /opt/ros/melodic/share/ros/core/rosbuild/rosbuild.cmake:7 (cmake_policy):
The OLD behavior for policy CMP0011 will be removed from a future version of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all policies are deprecated and that a policy should be set to OLD only under specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD. Call Stack (most recent call first):
CMakeLists.txt:2 (include)
CMake Deprecation Warning at /opt/ros/melodic/share/ros/core/rosbuild/rosbuild.cmake:16 (cmake_policy):
The OLD behavior for policy CMP0002 will be removed from a future version of CMake.
上面应该是CMake版本的问题
/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: 无法添加符号: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/Stereo.dir/build.make:176: 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
make[1]: *** 正在等待未完成的任务....
/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: 无法添加符号: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/RGBD.dir/build.make:176: 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
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
make[CMakeFiles/Stereo.dir/all]出错,因为目标’CMakeFiles/Stereo.dir/all’在生成makefiles失败。因为makefiles是根据CMakelist生成的,所以还是CMakeLists中出错,输出信息指出:ros_stereo.cc.o存在未引用符号,原因是没有连接到libboost_system.so库,链接报错。
解决办法:
打开catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2路径下的CMakeLists.txt,在
set中添加-lboost_system,如下:
set(LIBS
${OpenCV_LIBS}
${EIGEN3_LIBS}
${Pangolin_LIBRARIES}
${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so
${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so
${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so
-lboost_system#新添加
)
重新执行./build_ros.sh

2005

被折叠的 条评论
为什么被折叠?



