c++mingwglm-mathogreogre3d

Header conflict error with mingw32 (ogre3d+cegui+glm application)


I'm in the process of upgrading an ogre application into using a newer version of ogre and have run into some issues compiling this on windows with mingw, due to the upgraded libraries now using glm.

When compiling I run into a number of errors like this:

In file included from c:\mingw\bin../lib/gcc/i686-w64-mingw32/4.7.3/include/xmmintrin.h:36:0,
from C:/mingw/OgreSDK/include/OGRE/OgreCommon.h:35,
from C:/mingw/OgreSDK/include/OGRE/OgreMath.h:34,
from D:/Users/jacob/Documents/git/ThriveDirectReview2/src/engine/serialization.h:7,
from D:\Users\jacob\Documents\git\ThriveDirectReview2\src\engine\engine.cpp:8:
c:\mingw\bin../lib/gcc/i686-w64-mingw32/4.7.3/include/mmintrin.h:53:1: error: previous declaration of 'void _m_empty()' with 'C++' linkage
In file included from C:/mingw/install/include/glm/core/setup.hpp:549:0,
from C:/mingw/install/include/glm/glm.hpp:89,
from C:/mingw/install/include/cegui-9999/CEGUI/../CEGUI/Size.h:37,
from C:/mingw/install/include/cegui-9999/CEGUI/../CEGUI/Rect.h:33,
from C:/mingw/install/include/cegui-9999/CEGUI/../CEGUI/Image.h:33,
from C:/mingw/install/include/cegui-9999/CEGUI/../CEGUI/BitmapImage.h:30,
from C:/mingw/install/include/cegui-9999/CEGUI/../CEGUI/CEGUI.h:37,
from D:\Users\jacob\Documents\git\ThriveDirectReview2\src\engine\engine.cpp:21:

Looking at /glm/core/setup.hpp:549:0 we have:

if defined(MINGW32) && (GLM_ARCH != GLM_ARCH_PURE)
include intrin.h
endif

So ogre (graphics library) is using xmmintrin header from gcc, and cegui (gui library built for ogre) is using intrin.h also from gcc and both of these headers define pretty much the same interface and cause the conflicts.

All of the the relevant source code can be found here: https://github.com/Revolutionary-Games/Thrive/tree/ogre2.0

So it would appear that glm is incompatible with gcc which seems rather strange to me. What's more surprising is that cegui isn't working with ogre, so my first step was to post on the cegui forums: http://cegui.org.uk/forum/viewtopic.php?f=10&t=7024 but they we're unable to help.

This seems like a very specialized problem, perhaps too specialized for stack overflow but I hope you can help, or give a suggestion for a direction to circumvent the problem!

EDIT: Found out that both *intrin files are from gcc.


Solution

  • Seems this is an old gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56038

    Can't accept my own answer for 2 days.