编译 ./build_ros.h 出的错基本就是与这差不多的,方法相同,定位相关的库,然后移动位置,更改cmkelist.txt文件即可
我这里因为ORB_SLAM2用的opencv3,我装的也是opencv3,但是我的ROS noetic自带的是opencv4,所以冲突了
注意加粗部分
/usr/bin/ld: warning: libopencv_imgcodecs.so.4.2, needed by /opt/ros/noetic/lib/libcv_bridge.so, may conflict with libopencv_imgcodecs.so.3.4 /usr/bin/ld: warning: libopencv_core.so.4.2, needed by /opt/ros/noetic/lib/libcv_bridge.so, may conflict with libopencv_core.so.3.4 /usr/bin/ld: warning: libopencv_imgcodecs.so.4.2, needed by /opt/ros/noetic/lib/libcv_bridge.so, may conflict with libopencv_imgcodecs.so.3.4 /usr/bin/ld: warning: libopencv_core.so.4.2, needed by /opt/ros/[ 55%] Built target Mono noetic/lib/libcv_bridge.so, may conflict with libopencv_core.so.3.4 [ 66%] Built target RGBD make: *** [Makefile:130:all] 错误 2
出问题的就是 libopencv_imgcodecs.so与libopencv_core.so这两个共享库
定位下这两个库
locate libopencv_imgproc.so
locate libopencv_core.so
如图,其实很明显了,冲突了
我的opencv是3.4.15的,所以携带的相关库也为3.4.15版本,但是我的ROS为noetic版本,这个版本中为4.2的版本
第一种方法:重装opencv3 第二种方法:更改CMakeList.txt ,如下
选择什么版本的,具体看自己环境需要了,我这里要使用 3.4.15版本的。
复制这两个库到 ORB_SLAM2下的 lib 文件夹下
cp /home/diyu/opencv-3.4.15/build/lib/libopencv_imgproc.so lib/
cp /home/diyu/opencv-3.4.15/build/lib/libopencv_core.so lib/
此外,在 ORB_SLAM2/Examples/ROS/ORB_SLAM2路径下的 CMakeList.txt 文件中添加
${PROJECT_SOURCE_DIR}/../../../lib/libopencv_imgproc.so
${PROJECT_SOURCE_DIR}/../../../lib/libopencv_core.so
重新编译
./build_ros.sh
成功
|