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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With