tags:

views:

533

answers:

2

If I include both gtest/gtest.h and boost/math/distributions/poisson.hpp I get

/opt/local/include/boost/tr1/tuple.hpp:63: error: ‘tuple’ is already declared in this scope
/opt/local/include/boost/tr1/tuple.hpp:67: error: ‘make_tuple’ is already declared in this scope
/opt/local/include/boost/tr1/tuple.hpp:68: error: ‘tie’ is already declared in this scope
/opt/local/include/boost/tr1/tuple.hpp:68: error: ‘tie’ is already declared in this scope
/opt/local/include/boost/tr1/tuple.hpp:68: error: ‘tie’ is already declared in this scope
/opt/local/include/boost/tr1/tuple.hpp:68: error: ‘tie’ is already declared in this scope
/opt/local/include/boost/tr1/tuple.hpp:68: error: ‘tie’ is already declared in this scope
/opt/local/include/boost/tr1/tuple.hpp:68: error: ‘tie’ is already declared in this scope
/opt/local/include/boost/tr1/tuple.hpp:68: error: ‘tie’ is already declared in this scope
/opt/local/include/boost/tr1/tuple.hpp:68: error: ‘tie’ is already declared in this scope
/opt/local/include/boost/tr1/tuple.hpp:68: error: ‘tie’ is already declared in this scope
/opt/local/include/boost/tr1/tuple.hpp:68: error: ‘tie’ is already declared in this scope
/opt/local/include/boost/tr1/tuple.hpp:72: error: ‘tuple_size’ is already declared in this scope
/opt/local/include/boost/tr1/tuple.hpp:73: error: ‘tuple_element’ is already declared in this scope

How do I prevent these two library namespaces from colliding?

+1  A: 

Have you tried switching the order of the includes? It is possible the other header file handles things a little more gracefully.

Jesse
Unfortunately, changing the order (from gtest/boost to boost/gtest makes a larger mess).
bias
+6  A: 

Try building with BOOST_HAS_TR1_TUPLE defined. It looks like both boost and your std libraries are defining std::tr1::tuple and I can't see how to disable the std version. Looking at the boost header though it appears that BOOST_HAS_TR1_TUPLE needs to be defined to tell boost that std::tr1::tuple is already defined.

I got similar errors to yours when I tried to compile a file including both those headers and then they disappeared when I defined BOOST_HAS_TR1_TUPLE.

Troubadour
That worked perfect.
bias
This depends on the compiler version and on the gtest version.GTest also defines its own tuple unless the compiler is gcc 4+. So in this case boost would use the gtest implementation, which you probably don't want.But you can use the boost tuple in gtest also by setting GTEST_USE_OWN_TR1_TUPLE to 0.
housemaister