最近想在树莓派4b上的ROS系统运行ORB-SLAM2,过程中遇到了一个比较棘手的问题。虽然最后看似瞎猫碰死耗子解决了,但是不知道有没有遗留一些奇怪问题。这里做一个简单记录。
树莓派4b:安装了官方Ubuntu20 Server,随后再安装了ubuntu-desktop桌面。
安装了opencv3
ORB-SLAM2:官方版本。
最终遇到了ROS Noetic和ubuntu的opencv版本冲突,前者是opencv4,后者opencv3。问题如下:
/usr/bin/ld: warning: libopencv_imgproc.so.4.2, needed by /opt/ros/noetic/lib/libcv_bridge.so, may conflict with libopencv_imgproc.so.3.4
/usr/bin/ld: warning: libopencv_core.so.4.2, needed/usr/bin/ld: warning: libopencv_imgproc.so.4.2, needed by /opt/ros/noetic/lib/libcv_bridge.so, by /mayopt/ros/noetic/lib/libcv_bridge.so, may conflict with conflictlibopencv_core.so.3.4
/usr/ withbin/ld: CMakeFiles/Stereo.dir/src/ros_stereo.cc.o: undefined reference to symbol '_ZNK2cv8FileNodecviEv'
/usr/bin/ld: /usr/lib/aarch64-linux libopencv_imgproc.so.3.4
/usr/bin/ld: CMakeFiles/MonoAR.dir/src/AR/ViewerAR.cc.o: undefined reference to symbol '_ZN2cv7putTextERKNS_17_InputOutputArrayERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_6Point_IiEEidNS_7Scalar_IdEEiib'
/usr/bin/ld: /usr/lib/aarch64-linux-gnu/libopencv_imgproc.so.4.2.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
-gnu/libopencv_core.so.4.2.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/MonoAR.dir/build.make:268: ../MonoAR] Error 1
make[1]: *** [CMakeFiles/Makefile2:541: CMakeFiles/MonoAR.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/Stereo.dir/build.make:198: ../Stereo] Error 1
make[1]: *** [CMakeFiles/Makefile2:568: CMakeFiles/Stereo.dir/all] Error 2
/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_core.so.4.2, needed by /opt/ros/noetic/lib/libcv_bridge.so, may conflict with libopencv_core.so.3.4
[ 55%] Built target Mono
[ 66%] Built target RGBD
make: *** [Makefile:130: all] Error 2
ROS系统要libopencv_core.so.4.2,libopencv_imgproc.so.4.2,但是ORB-SLAM2的Cmakelist用的是libopencv_core.so.3.4,libopencv_imgproc.so.3.4。
看了下网上介绍,大致有三种解法:
1 换个用opencv4的ORB-SLAM2, github上有 https://github.com/mateomd-dev/orb-slam2。
2 让ROS cv_bridge采用opencv3,或者重新安装一个cv_bridge。
3 引入libopencv_core.so.4.2,libopencv_imgproc.so.4.2。
本人用的是方法3,坦白说这个是我实验了很多遍才找到的,并非是我有什么理论认识。具体做法是ros的cmakelist.txt中加入以下
/usr/local/lib/libopencv_core.so.3.4
/usr/local/lib/libopencv_imgproc.so.3.4
/usr/lib/aarch64-linux-gnu/libopencv_core.so.4.2
/usr/lib/aarch64-linux-gnu/libopencv_imgproc.so.4.2
-lboost_system
结果如下:文章来源:https://www.toymoban.com/news/detail-485537.html
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
/usr/local/lib/libopencv_core.so.3.4
/usr/local/lib/libopencv_imgproc.so.3.4
/usr/lib/aarch64-linux-gnu/libopencv_core.so.4.2
/usr/lib/aarch64-linux-gnu/libopencv_imgproc.so.4.2
-lboost_system
)
就这样~文章来源地址https://www.toymoban.com/news/detail-485537.html
到了这里,关于warning: libopencv_core.so.4.2, needed by /opt/ros/noetic/lib/libcv_bridge.so, may conflict with lib的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!