Hi.
I'm still in my quest toward switching my pet projects from Visual Studio to Code::Blocks, and apparently the last hurdle I have (well, until another one happens

) is to manage rebuilding my picture converter using Code::Blocks.
This converter (PictConv:
http://www.defence-force.org/computing/oric/coding/annexe_3/pictconv) is using the FreeImage library (
http://freeimage.sourceforge.net) to load and save the pictures.
The oldest versions of FreeImage were coded in C, so it was not a problem to link the .lib file in any particular compiler. Unfortunately (or not, it's a good thing that the library evolved) the library is now using C++ internally, with exceptions and stuff, and as a result the library file is not accepted by mingw, got a lot of undefined references:
-------------
libs\FreeImage.lib(./release/FIRational.obj)
.text$x+0x4): undefined reference to `??1exception@std@@UAE@XZ'
libs\FreeImage.lib(./release/FIRational.obj)
.text$x+0xe): undefined reference to `___CxxFrameHandler3'
libs\FreeImage.lib(./release/FIRational.obj)
.text[?str@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ]+0x115): undefined reference to `??3@YAXPAX@Z'-------------
So well, I downloaded the latest source code (
http://downloads.sourceforge.net/freeimage/FreeImage3110.zip) and try to rebuild the library myself.
Code::Blocks imported the SLN file without any problem, the whole project appears exactly like in visual studio, but unfortunately mingw can't compile it due to apparently a lot of "trickery" in the header files:
-------------
../FreeImage.h:156: error: conflicting declaration 'typedef uint32_t DWORD'
e:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windef.h:229: error: 'DWORD' has a previous declaration as `typedef long unsigned int DWORD'
../FreeImage.h:156: error: declaration of `typedef uint32_t DWORD'
e:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windef.h:229: error: conflicts with previous declaration `typedef long unsigned int DWORD'
../FreeImage.h:156: error: declaration of `typedef uint32_t DWORD'
e:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windef.h:229: error: conflicts with previous declaration `typedef long unsigned int DWORD'
../FreeImage.h:157: error: conflicting declaration 'typedef int32_t LONG'
e:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/winnt.h:79: error: 'LONG' has a previous declaration as `typedef long int LONG'
../FreeImage.h:157: error: declaration of `typedef int32_t LONG'
e:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/winnt.h:79: error: conflicts with previous declaration `typedef long int LONG'
../FreeImage.h:157: error: declaration of `typedef int32_t LONG'
e:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/winnt.h:79: error: conflicts with previous declaration `typedef long int LONG'
../FreeImage.h:173: error: redefinition of `struct tagRGBQUAD'
e:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/wingdi.h:1403: error: previous definition of `struct tagRGBQUAD'
../FreeImage.h:184: error: ISO C++ forbids declaration of `RGBQUAD' with no type
../FreeImage.h:184: error: conflicting declaration 'typedef int RGBQUAD'-------------
The reason is that FreeImage is using some Windows types in the public API, and since they do not exist on Mac and Linux, they had to redefine the types in "freeimage.h":
-------------
typedef struct tagRGBQUAD {
#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR
BYTE rgbBlue;
BYTE rgbGreen;
BYTE rgbRed;
#else
BYTE rgbRed;
BYTE rgbGreen;
BYTE rgbBlue;
#endif // FREEIMAGE_COLORORDER
BYTE rgbReserved;
} RGBQUAD;
-------------
The problem is that mingw apparently did something similar, with the same types defined in 'wingdi.h', but not exactly as the original MS header files did it.
So as a result, due to the order of inclusion of the various header files, the whole system is not working under mingw.
I tried to "fix" the ones in wingdi.h to solve the problem (by doing some ugly magic), but then it failed on some other structure in some other files.
I'm posting that here instead of on the mingw list because people here seem more reactive

So, if anyone has an idea on how to solve this issue, this would be great !
Thanks a lot
