Eigen3, MinGW: compilation failure, intrin.h does not exist
Submitted by Matt
Assigned to Eamon Nerbonne
Link to original bugzilla bug (#125)
Version: 3.0
Operating system: Windows
Description
Currently trying out Eigen 3.0-beta2 (2010-10-15).
There seems to be a problem in file "eigen\Eigen\Core" -- right here:
// include files
#if (defined GNUC) && (defined MINGW32)
#include <intrin.h>
//including intrin.h works around a MINGW bug http://sourceforge.net/tracker/?func=detail&atid=102435&aid=2962480&group_id=2435
//in essence, intrin.h is included by windows.h and also declares intrinsics (just as emmintrin.h etc. below do). However,
//intrin.h uses an extern "C" declaration, and g++ thus complains of duplicate declarations with conflicting linkage. The linkage for intrinsics
//doesn't matter, but at that stage the compiler doesn't know; so, to avoid compile errors when windows.h is included after Eigen/Core,
//include intrin here.
#endif
Despite the claim made in the above comment, there is no "intrin.h" file in MinGW.
Tested both under the "g++-4.3.0-20080502-mingw32-alpha" as well as "g++ (GCC) 4.5.0" (which is the current official MinGW.org release, installed by the automatic installer dated 2010-10-30, i.e. "mingw-get-inst-20101030.exe").
Incidentally, neither does "include/windows.h" in any of the above versions include any header file containing "intrin" in its name.
This prevents a successful compilation -- e.g. if a file "example.cpp" contains
#include "Eigen/Dense"
in line 4, then the compilation fails:
In file included from ../Eigen/Dense:1:0,
from example.cpp:4:
../Eigen/Core:97:26: fatal error: intrin.h: No such file or directory
compilation terminated.
I've tried two workarounds:
(0) comment out #include <intrin.h> (since it doesn't exist on MinGW)
(1) since my CPU's ISA is x86, replace it with #include <x86intrin.h> (which exists in MinGW since at least GCC 4.3.0)
Then, the code seemingly compiles, but it's unclear whether which one (if any) correctly solves the problem.
On top of that, irrespectively of whether (0) or (1) was tried, experiencing SEGFAULTs in SSE2/OpenMP environment -- please advise, should I file a separate report on that or wait for the resolution of this one first (or should I provide additional information on the second bug as well in this report, as they may be related)?
Forum thread, with additional another problem (the above, SSE2) report:
http://forum.kde.org/viewtopic.php?f=74&t=91709