Boost、OpenCV 和 Eigen 库之间有冲突吗?

发布于 2024-10-23 18:56:53 字数 2847 浏览 7 评论 0原文

我的问题与 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一人独醉 2024-10-30 18:56:53

在包含 Eigen 之前使用 boost::filesystem 命名空间会导致编译器失败:

#include <boost/filesystem.hpp>
using namespace boost::filesystem;
#include <Eigen/Core>

失败,但

#include <boost/filesystem.hpp>
#include <Eigen/Core>
using namespace boost::filesystem;

可以工作。

原因是,如果将 boost::filesystem 添加到全局命名空间,就会污染它,并导致一些依赖于未污染命名空间的代码(此处为:eigen)在编译期间导致错误。这没什么奇怪的。通常,在包含完成之前,您不应该放置“using”行。

Using the boost::filesystem namespace before including Eigen causes the compiler to fail:

#include <boost/filesystem.hpp>
using namespace boost::filesystem;
#include <Eigen/Core>

fails, but

#include <boost/filesystem.hpp>
#include <Eigen/Core>
using namespace boost::filesystem;

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文