编译时由于不同的opencv版本而导致声明冲突

时间:2019-06-17 19:15:51

标签: c++ opencv cmake

在尝试构建lsd-slam_noros软件包时出现以下错误。总体而言,此软件包依赖于另外两个软件包openFABmapg2o,它们都可以正确编译。编译lsd-slam模块时,出现以下错误。

In file included from /usr/local/include/opencv2/features2d/features2d.hpp:48:0,
                 from /home/vivJune_2019/lsd_slam_noros-master/thirdparty/openFabMap/include/bowmsctrainer.hpp:58,
                 from /home/vivJune_2019/lsd_slam_noros-master/thirdparty/openFabMap/include/openfabmap.hpp:59,
                 from /home/vivJune_2019/lsd_slam_noros-master/lsd_slam/global_mapping/fab_map.cc:41:
/usr/local/include/opencv2/features2d.hpp:231:19: error: conflicting declaration ‘typedef class cv::Feature2D cv::FeatureDetector’
 typedef Feature2D FeatureDetector;
                   ^
In file included from /home/vivJune_2019/lsd_slam_noros-master/lsd_slam/global_mapping/fab_map.cc:22:0:
/home/vivJune_2019/lsd_slam_noros-master/lsd_slam/global_mapping/fab_map.h:29:7: note: previous declaration as ‘class cv::FeatureDetector’
 class FeatureDetector;

bowmsctrainer.hpp(?)中的声明相比,该错误表明文件fab_map.h中的声明问题。我不确定如何解决此声明冲突。

请帮助!

这是构建过程中更完整的日志(bowmsctrainer是在当前部分之前构建的)

Scanning dependencies of target openFABMAP
[  2%] Building CXX object thirdparty/openFabMap/CMakeFiles/openFABMAP.dir/src/inference.cpp.o
[  5%] Building CXX object thirdparty/openFabMap/CMakeFiles/openFABMAP.dir/src/chowliutree.cpp.o
[  8%] Building CXX object thirdparty/openFabMap/CMakeFiles/openFABMAP.dir/src/msckd.cpp.o
[ 11%] Building CXX object thirdparty/openFabMap/CMakeFiles/openFABMAP.dir/src/bowmsctrainer.cpp.o
[ 14%] Building CXX object thirdparty/openFabMap/CMakeFiles/openFABMAP.dir/src/fabmap.cpp.o
[ 17%] Linking CXX static library ../../../lib/libopenFABMAP.a
[ 17%] Built target openFABMAP
Scanning dependencies of target lsd_slam
[ 20%] Building CXX object lsd_slam/CMakeFiles/lsd_slam.dir/depth_estimation/depth_map_pixel_hypothesis.cc.o
[ 22%] Building CXX object lsd_slam/CMakeFiles/lsd_slam.dir/depth_estimation/depth_map.cc.o
[ 25%] Building CXX object lsd_slam/CMakeFiles/lsd_slam.dir/global_mapping/trackable_key_frame_search.cc.o
[ 28%] Building CXX object lsd_slam/CMakeFiles/lsd_slam.dir/global_mapping/g2o_type_sim3_sophus.cc.o
[ 31%] Building CXX object lsd_slam/CMakeFiles/lsd_slam.dir/global_mapping/fab_map.cc.o

In file included from /usr/local/include/opencv2/features2d/features2d.hpp:48:0,
                 from /home/vivJune_2019/lsd_slam_noros-master/thirdparty/openFabMap/include/bowmsctrainer.hpp:58,
                 from /home/vivJune_2019/lsd_slam_noros-master/thirdparty/openFabMap/include/openfabmap.hpp:59,
                 from /home/vivJune_2019/lsd_slam_noros-master/lsd_slam/global_mapping/fab_map.cc:41:
/usr/local/include/opencv2/features2d.hpp:231:19: error: conflicting declaration ‘typedef class cv::Feature2D cv::FeatureDetector’
 typedef Feature2D FeatureDetector;
                   ^
In file included from /home/vivJune_2019/lsd_slam_noros-master/lsd_slam/global_mapping/fab_map.cc:22:0:
/home/vivJune_2019/lsd_slam_noros-master/lsd_slam/global_mapping/fab_map.h:29:7: note: previous declaration as ‘class cv::FeatureDetector’
 class FeatureDetector;

fab_map.h的相关(部分)内容(可能)是:

#include <opencv2/core/core.hpp>

namespace of2 {
class FabMap;
}
namespace cv {
    class FeatureDetector;
    class BOWImgDescriptorExtractor;
}

0 个答案:

没有答案