This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Conflict with Boost (Eigen not compiling)

Tags: None
(comma "," separated)
Phraides
Registered Member
Posts
7
Karma
0
Hello,

I am having some compilation problems due to a conflict between boost 1.46 and Eigen 3.0.0 (same behaviour with the dev branch as of today), maybe you guys can help me. I am on Linux using gcc 4.4.0 (the problem doesn't appear on Windows with Visual Studio 2010).

So first I got this error:

Code: Select all
Eigen/src/Core/util/Constants.h:277: error: expected identifier before numeric constant


that corresponds to this code:

Code: Select all
enum ComputationInfo {
  Success = 0, // <- The compiler errors here
  NumericalIssue = 1,
  NoConvergence = 2
};


I solved that by putting the following before the enum:

Code: Select all
#undef Success


I am not sure it's very clean, and I am not sure this one is related to boost so let's continue to the main problem. Similarly to this person (http://stackoverflow.com/questions/5327325/conflict-between-boost-opencv-and-eigen-libraries), I get this:

Code: Select all
In file included from /share/apps/boost-1.46/boost/filesystem/v3/path_traits.hpp:22,
                 from /share/apps/boost-1.46/boost/filesystem/v3/path.hpp:25,
                 from /share/apps/boost-1.46/boost/filesystem/v3/operations.hpp:25,
                 from /share/apps/boost-1.46/boost/filesystem/operations.hpp:31,
                 from src/Database.h:9,
                 from src/Network.h:7,
                 from src/Network.cpp:1:
/share/apps/boost-1.46/boost/type_traits/decay.hpp: At global scope:
/share/apps/boost-1.46/boost/type_traits/decay.hpp: In instantiation of 'boost::decay<Eigen::<anonymous enum> >':
include/eigen-eigen-769b4de51640/Eigen/src/Core/GenericPacketMath.h:293:   instantiated from here
/share/apps/boost-1.46/boost/type_traits/decay.hpp:28: error: 'Eigen::<anonymous enum>' is/uses anonymous type
/share/apps/boost-1.46/boost/type_traits/decay.hpp:28: error:   trying to instantiate 'template<class T> struct boost::remove_reference'
/share/apps/boost-1.46/boost/type_traits/decay.hpp:38: error: 'Eigen::<anonymous enum>' is/uses anonymous type
/share/apps/boost-1.46/boost/type_traits/decay.hpp:38: error:   trying to instantiate 'template<class T> struct boost::remove_reference'


I don't put the whole output cause it's too long, but it goes on for the following files, with the same error about "anonymous type":

Code: Select all
include/eigen-eigen-769b4de51640/Eigen/src/Core/Assign.h:84
include/eigen-eigen-769b4de51640/Eigen/src/Core/util/BlasUtil.h:137
include/eigen-eigen-769b4de51640/Eigen/src/Core/DiagonalProduct.h:42
include/eigen-eigen-769b4de51640/Eigen/src/Core/TriangularMatrix.h:114:   
include/eigen-eigen-769b4de51640/Eigen/src/Core/PlainObjectBase.h:583:   
include/eigen-eigen-769b4de51640/Eigen/src/Core/Matrix.h:142


Does anyone know how to solve this?
Cheers
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Hi,

regarding the Success issue you should blame the lib which is defining it as a preprocessor token and I strongly doubt that comes from boost.

Regarding the other issues, a short test case would help to reproduce and investigate....
Phraides
Registered Member
Posts
7
Karma
0
Hello,

Thanks for your reply. For the boost issue, there isn't really any test case, as the compilation fails on the line where I include the boost header:

Code: Select all
#include <boost/filesystem/operations.hpp>


I had a look at the lines are indicated by the compiler, in the Eigen file GenericPacketMath.h:293 we find that:

Code: Select all
template<typename Packet, int LoadMode>
inline Packet ploadt(const typename unpacket_traits<Packet>::type* from)
{
  if(LoadMode == Aligned) // <- that's line 293
    return pload<Packet>(from);
  else
    return ploadu<Packet>(from);
}


and in the boost file decay.hpp:28

Code: Select all
 template< class T >
    struct decay
    {
    private:
        typedef BOOST_DEDUCED_TYPENAME remove_reference<T>::type Ty; // <- that's line 28
    public:
        typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<
            is_array<Ty>,
            mpl::identity<BOOST_DEDUCED_TYPENAME remove_bounds<Ty>::type*>,
            BOOST_DEDUCED_TYPENAME mpl::eval_if<
                is_function<Ty>,
                add_pointer<Ty>,
                mpl::identity<Ty>
            >
        >::type type;
    };


I can't see any relations between those two things, I am quite clueless on this one...
jitseniesen
Registered Member
Posts
204
Karma
2
I tried to reproduce but did not manage. I have gcc 4.4.5 and boost 1.46. I tried to compile the following code:

Code: Select all
#include <boost/filesystem.hpp>
#include <Eigen/Core>

int main()
{
}


This compiles fine. Do you include any more header files than this?

If your compiler gives errors on this code, then perhaps it's a bug in gcc 4.4.0 that's fixed in 4.4.5.
Phraides
Registered Member
Posts
7
Karma
0
I will try to reduce my code to a minimum size and post an example which fails to compile. I'll post soon!
Phraides
Registered Member
Posts
7
Karma
0
Ok I seem to have found it, the following code doesn't compile:

Code: Select all
#include <boost/filesystem.hpp>
using namespace boost::filesystem;

#include <Eigen/Core>
using namespace Eigen;

int main()
{
return 0;
}


but the following works:

Code: Select all
#include <boost/filesystem.hpp>
#include <Eigen/Core>

using namespace boost::filesystem;
using namespace Eigen;

int main()
{
return 0;
}


Basically, using the boost::filesystem namespace before including Eigen is the cause of the error.

Is there a logical explanation for that? I guess I will have to put them somewhere in a header file in that specific order to be able to compile...
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
You should never put a using namespace declarative before including any header file, just like you should never put any using namespace declarative in header files.

BTW: Your example compiles fine here.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora