← Back to team overview

dolfin team mailing list archive

uBlas/PETSc header collision for GCC 3.3.5

 

Hi,

This is not a DOLFIN-specific issue, but it's good to be aware of it.

There is a collision between the uBlas and PETSc headers (perhaps the
same symbol is declared in both) which causes errors if the headers
are included in a certain order. This problem appears with GCC 3.3.5
but seems to disappear with GCC 4.0+.

A simple test case demonstrating the error:

#include <petscvec.h>
#include <boost/numeric/ublas/matrix.hpp>

int main()
{

  return 0;
}

gives:

g++ -I/usr/local/lib/petsc/ -I/usr/local/lib/petsc//bmake/linux-gnu -I/usr/local/lib/petsc//include -I/usr/include/mpi -c collision.cpp
In file included from /usr/include/boost/mpl/int.hpp:20,
                 from /usr/include/boost/mpl/lambda_fwd.hpp:23,
                 from /usr/include/boost/mpl/aux_/na_spec.hpp:18,
                 from /usr/include/boost/mpl/if.hpp:19,
                 from /usr/include/boost/numeric/ublas/detail/config.hpp:28,
                 from /usr/include/boost/numeric/ublas/exception.hpp:29,
                 from /usr/include/boost/numeric/ublas/storage.hpp:25,
                 from /usr/include/boost/numeric/ublas/vector.hpp:20,
                 from /usr/include/boost/numeric/ublas/matrix.hpp:20,
                 from collision.cpp:2:
/usr/include/boost/mpl/aux_/integral_wrapper.hpp:43: error: parse error before
   `=' token
/usr/include/boost/mpl/aux_/integral_wrapper.hpp:51: error: typedef `
   mpl_::int__gierr' is initialized (use __typeof__ instead)
/usr/include/boost/mpl/aux_/integral_wrapper.hpp:51: error: `typedef int
   mpl_::int__gierr' redeclared as different kind of symbol
...

if we reverse the order:

#include <boost/numeric/ublas/matrix.hpp>
#include <petscvec.h>

int main()
{

  return 0;
}

the errors don't appear.

I can't see the cause of the errors, perhaps we should notify the
uBlas and PETSc developers if it leads to more problems.

I've worked around the problem by making sure PETSc is included after
uBlas (dolfin.h includes them in that order, I triggered the error by
including dolfin/Vector.h before dolfin.h). Using GCC 4.0+ also seems
to avoid the error.

  Johan



Follow ups