orbslam2 + opencv2 中的bug

xiaoxiao2021-03-01  20

bug是:

/usr/bin/ld: CMakeFiles/stereo_euroc.dir/Examples/Stereo/stereo_euroc.cc.o: undefined reference to symbol '_ZN2cv11FileStorageC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiS8_' /usr/local/lib/libopencv_core.so.2.4: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status CMakeFiles/stereo_euroc.dir/build.make:162: recipe for target '../Examples/Stereo/stereo_euroc' failed make[2]: *** [../Examples/Stereo/stereo_euroc] Error 1 CMakeFiles/Makefile2:289: recipe for target 'CMakeFiles/stereo_euroc.dir/all' failed make[1]: *** [CMakeFiles/stereo_euroc.dir/all] Error 2 make[1]: *** 正在等待未完成的任务.... CMakeFiles/mono_kitti.dir/Examples/Monocular/mono_kitti.cc.o:在函数‘main’中: mono_kitti.cc:(.text.startup+0x336):对‘cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’未定义的引用 ../lib/libORB_SLAM2.so:对‘cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)’未定义的引用 ../lib/libORB_SLAM2.so:对‘cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’未定义的引用 collect2: error: ld returned 1 exit status CMakeFiles/mono_kitti.dir/build.make:162: recipe for target '../Examples/Monocular/mono_kitti' failed make[2]: *** [../Examples/Monocular/mono_kitti] Error 1 CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/mono_kitti.dir/all' failed make[1]: *** [CMakeFiles/mono_kitti.dir/all] Error 2 CMakeFiles/stereo_kitti.dir/Examples/Stereo/stereo_kitti.cc.o:在函数‘main’中: stereo_kitti.cc:(.text.startup+0x3ee):对‘cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’未定义的引用 stereo_kitti.cc:(.text.startup+0x583):对‘cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’未定义的引用 ../lib/libORB_SLAM2.so:对‘cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)’未定义的引用 ../lib/libORB_SLAM2.so:对‘cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’未定义的引用 collect2: error: ld returned 1 exit status CMakeFiles/stereo_kitti.dir/build.make:162: recipe for target '../Examples/Stereo/stereo_kitti' failed make[2]: *** [../Examples/Stereo/stereo_kitti] Error 1 CMakeFiles/Makefile2:252: recipe for target 'CMakeFiles/stereo_kitti.dir/all' failed make[1]: *** [CMakeFiles/stereo_kitti.dir/all] Error 2 CMakeFiles/mono_euroc.dir/Examples/Monocular/mono_euroc.cc.o:在函数‘main’中: mono_euroc.cc:(.text.startup+0x366):对‘cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’未定义的引用 ../lib/libORB_SLAM2.so:对‘cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)’未定义的引用 ../lib/libORB_SLAM2.so:对‘cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’未定义的引用 collect2: error: ld returned 1 exit status CMakeFiles/mono_euroc.dir/build.make:162: recipe for target '../Examples/Monocular/mono_euroc' failed make[2]: *** [../Examples/Monocular/mono_euroc] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/mono_euroc.dir/all' failed make[1]: *** [CMakeFiles/mono_euroc.dir/all] Error 2 CMakeFiles/mono_tum.dir/Examples/Monocular/mono_tum.cc.o:在函数‘main’中: mono_tum.cc:(.text.startup+0x504):对‘cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’未定义的引用 ../lib/libORB_SLAM2.so:对‘cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)’未定义的引用 ../lib/libORB_SLAM2.so:对‘cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’未定义的引用 collect2: error: ld returned 1 exit status CMakeFiles/rgbd_tum.dir/Examples/RGB-D/rgbd_tum.cc.o:在函数‘main’中: rgbd_tum.cc:(.text.startup+0x5a4):对‘cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’未定义的引用 rgbd_tum.cc:(.text.startup+0x8d7):对‘cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’未定义的引用 ../lib/libORB_SLAM2.so:对‘cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)’未定义的引用 ../lib/libORB_SLAM2.so:对‘cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’未�CMakeFiles/mono_tum.dir/build.make:162: recipe for target '../Examples/Monocular/mono_tum' failed ����make[2]: *** [../Examples/Monocular/mono_tum] Error 1 �的引用 collect2: error: ld returned 1 exit status CMakeFiles/Makefile2:141: recipe for target 'CMakeFiles/mono_tum.dir/all' failed make[1]: *** [CMakeFiles/mono_tum.dir/all] Error 2 CMakeFiles/rgbd_tum.dir/build.make:162: recipe for target '../Examples/RGB-D/rgbd_tum' failed make[2]: *** [../Examples/RGB-D/rgbd_tum] Error 1 CMakeFiles/Makefile2:215: recipe for target 'CMakeFiles/rgbd_tum.dir/all' failed make[1]: *** [CMakeFiles/rgbd_tum.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2

 

为了这个问题查了一个下午,发现不过是opencv版本问题:

在ORBSLAM2中的CMakeLists.txt中,

find_package(OpenCV 2.4.9 QUIET) if(NOT OpenCV_FOUND)    find_package(OpenCV 3.4.1 QUIET)    if(NOT OpenCV_FOUND)       message(FATAL_ERROR "OpenCV > 2.4.3 not found.")    endif() endif()

不明白原理是什么,但是最好把你电脑中的opencv版本放在第一个find_package中,我ubuntu中的opencv版本为2.4.9;

因此调换了顺序,即成功编译了:

[ 65%] Building CXX object CMakeFiles/mono_kitti.dir/Examples/Monocular/mono_kitti.cc.o [ 68%] Building CXX object CMakeFiles/mono_tum.dir/Examples/Monocular/mono_tum.cc.o [ 71%] Building CXX object CMakeFiles/rgbd_tum.dir/Examples/RGB-D/rgbd_tum.cc.o [ 75%] Building CXX object CMakeFiles/mono_euroc.dir/Examples/Monocular/mono_euroc.cc.o [ 78%] Building CXX object CMakeFiles/stereo_euroc.dir/Examples/Stereo/stereo_euroc.cc.o [ 81%] Building CXX object CMakeFiles/stereo_kitti.dir/Examples/Stereo/stereo_kitti.cc.o [ 84%] Linking CXX executable ../Examples/RGB-D/rgbd_tum [ 87%] Linking CXX executable ../Examples/Stereo/stereo_euroc [ 93%] Linking CXX executable ../Examples/Stereo/stereo_kitti [ 93%] Linking CXX executable ../Examples/Monocular/mono_tum [ 96%] Linking CXX executable ../Examples/Monocular/mono_kitti [100%] Linking CXX executable ../Examples/Monocular/mono_euroc [100%] Built target stereo_euroc [100%] Built target rgbd_tum [100%] Built target mono_kitti [100%] Built target mono_tum [100%] Built target mono_euroc [100%] Built target stereo_kitti

 

转载请注明原文地址: https://www.6miu.com/read-3649992.html

最新回复(0)