我的问题与在Eclipse CDR中静态链接Boost和OpenCV库时出现错误有关,而我想做的比这里描述的更多:如何使用Boost和OpenCV创建一个可以读取文件夹中所有图像的程序?,也就是使用Boost的文件系统库遍历一个目录,并对其中的图片文件进行一些OpenCV处理。
我使用MinGW编译了filesystem等库,并尝试在Windows 7 64位系统上使用Eclipse CDT运行Boost 1.45、OpenCV 2.2和Eigen2。如果单独在项目中使用文件系统库,则可以编译和运行,但与上述两个库结合使用时,会出现以下错误:
In file included from C:\boost_1_45_0/boost/filesystem/v3/path_traits.hpp:22:0,
from C:\boost_1_45_0/boost/filesystem/v3/path.hpp:25,
from C:\boost_1_45_0/boost/filesystem.hpp:32,
from ..\src\ComputeNatScaleFunction.cpp:18:
C:\boost_1_45_0/boost/type_traits/decay.hpp: In instantiation of 'boost::decay<cv::<anonymous enum> >':
C:\cmake_binaries\include/opencv2/core/operations.hpp:766:23: instantiated from here
C:\boost_1_45_0/boost/type_traits/decay.hpp:28:66: error: 'cv::' is/uses anonymous type
C:\boost_1_45_0/boost/type_traits/decay.hpp:28:66: error: trying to instantiate 'template struct boost::remove_reference'
C:\boost_1_45_0/boost/type_traits/decay.hpp:38:17: error: 'cv::' is/uses anonymous type
C:\boost_1_45_0/boost/type_traits/decay.hpp:38:17: error: trying to instantiate 'template struct boost::remove_reference'
C:\boost_1_45_0/boost/type_traits/decay.hpp: In instantiation of 'boost::decay<cv::<anonymous enum> >':
C:\cmake_binaries\include/opencv2/core/operations.hpp:917:21: instantiated from here
C:\boost_1_45_0/boost/type_traits/decay.hpp:28:66: error: 'cv::' is/uses anonymous type
C:\boost_1_45_0/boost/type_traits/decay.hpp:28:66: error: trying to instantiate 'template struct boost::remove_reference'
C:\boost_1_45_0/boost/type_traits/decay.hpp:38:17: error: 'cv::' is/uses anonymous type
C:\boost_1_45_0/boost/type_traits/decay.hpp:38:17: error: trying to instantiate 'template struct boost::remove_reference'
C:\boost_1_45_0/boost/type_traits/decay.hpp: In instantiation of 'boost::decay<Eigen::<anonymous enum> >':
C:\Eigen2/Eigen/src/Core/GenericPacketMath.h:116:18: instantiated from here
C:\boost_1_45_0/boost/type_traits/decay.hpp:28:66: error: 'Eigen::' is/uses anonymous type
C:\boost_1_45_0/boost/type_traits/decay.hpp:28:66: error: trying to instantiate 'template struct boost::remove_reference'
C:\boost_1_45_0/boost/type_traits/decay.hpp:38:17: error: 'Eigen::' is/uses anonymous type
C:\boost_1_45_0/boost/type_traits/decay.hpp:38:17: error: trying to instantiate 'template struct boost::remove_reference'
任何提示可以解释这些库之间为什么会发生冲突吗?编译器无法通过包含文件系统(即第18行)的步骤。
namespace bfs = boost::filesystem;
的语句来减少输入的类型负担 ";)"。 - rubenvbusing
指令之前,您应始终包含所有头文件。在您的情况下,您正在将许多符号引入全局命名空间,这可能会“混淆”Eigen。 - Ferdinand Beyerusing namespace boost::filesystem
" 将boost::filesystem
中的所有符号名称都导入到全局命名空间,因此如果boost::filesystem
有一个名为Foo
的类,而Eigen
也有一个名为Foo
的类,则它们会冲突,编译器将不知道使用哪个。 - Catskul