Boost、OpenCV 和 Eigen 库之间有冲突吗?
我的问题与 Boost 的静态链接有些相关以及带有 Eclipse CDR 的 OpenCV 库。错误,而我尝试做的事情比这里描述的要多一些: 如何使用Boost和OpenCV创建一个可以读取文件夹中所有图像的程序?,即使用遍历目录Boost 的文件系统库并使用 OpenCV 对图像文件进行一些处理。
我使用 MinGW 编译了文件系统和其他库,并尝试在 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 行)。
my question is somewhat related to Static linking of Boost and OpenCV libs with Eclipse CDR. errors, whereas I'm trying to do a bit more than described here: How to create a program that can read all the images in folder using Boost and OpenCV?, namely traverse a directory using Boost's filesystem library and do some processing on the image files with OpenCV.
I compiled filesystem and other libraries with MinGW, and try to run Boost 1.45, OpenCV 2.2 and Eigen2 with Eclipse CDT on a Windows 7 64-bit system. The filesystem library compiles and runs without problems if used in a project by itself, but in combination with the other two libraries from above, I get the following errors:
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'
etc.
Any hints as to why these libraries might conflict with each other? The compiler is not getting past the include of filesystem (i.e. line 18).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在包含 Eigen 之前使用 boost::filesystem 命名空间会导致编译器失败:
失败,但
可以工作。
原因是,如果将 boost::filesystem 添加到全局命名空间,就会污染它,并导致一些依赖于未污染命名空间的代码(此处为:eigen)在编译期间导致错误。这没什么奇怪的。通常,在包含完成之前,您不应该放置“using”行。
Using the boost::filesystem namespace before including Eigen causes the compiler to fail:
fails, but
works.
The reason is that if boost::filesystem is added to the global namespace, it pollutes it, and causes some code (here: eigen) that depends on unpolluted namespace to cause errors during compilation. There's nothing strange about it. Normally you should never put "using" lines before your includes are finished.