我在使用 Boost 库时遇到问题,尤其是在与 OpenCV 一起使用时的文件系统。显然,该问题类似于 Conflict between Boost, OpenCV and Eigen libraries? 中描述的问题.在这种特殊情况下,通过在“using namespace”语句之前加上所有“#include”语句来解决问题。就我而言,这是从一开始就以这种方式完成的。
我正在使用 OpenCV 2.4.3 和 Boost 1.48(已经尝试使用 1.52,但问题完全相同)。编程是在 Windows 7(64 位)中使用 Eclipse CPP 插件和 MinGW 完成的。
尝试构建我的程序时出现以下错误:
C:\Boost\boost_1_48_0/boost/type_traits/decay.hpp:28:66: error: 'cvflann::<anonymous enum>' is/uses anonymous type
C:\Boost\boost_1_48_0/boost/type_traits/decay.hpp:28:66: error: trying to instantiate 'template<class T> struct boost::remove_reference'
C:\Boost\boost_1_48_0/boost/type_traits/decay.hpp:38:17: error: 'cvflann::<anonymous enum>' is/uses anonymous type
C:\Boost\boost_1_48_0/boost/type_traits/decay.hpp:38:17: error: trying to instantiate 'template<class T> struct boost::remove_reference'
在我的例子中,using namespace 语句在 include 语句之后:
#include <opencv2/opencv.hpp>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <boost/filesystem.hpp>
#include <boost/multi_index_container.hpp>
using namespace std;
using namespace cv;
using namespace boost::filesystem;
任何关于如何解决这个问题的想法将不胜感激:D:D:D
问候, 路易斯
最佳答案
我建议您删除该部分:
using namespace std;
using namespace cv;
using namespace boost::filesystem;
并使用作用域运算符 ::
在代码中。
Here's an example这两种不同的模式。
关于c++ - OpenCV 和 Boost 文件系统之间的冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14460567/