MinGW report


#1

Just a report that I have built JUCE using gcc tdm 4.4.0 under MinGW environment using external libraries (zlib, png, jpeg, ogg, flac)…

I don’t know official state of support for MinGW, but here is the diff of amalgamated file:

--- /F/msys/svn/juce/juce_amalgamated.cpp	2009-06-29 14:39:56 +0200
+++ juce_amalgamated.cpp	2009-07-03 15:38:37 +0200
@@ -627,8 +627,12 @@
 
     HRESULT CoCreateInstance (REFCLSID rclsid, DWORD dwClsContext)
     {
+#ifndef __MINGW32__
         operator= (0);
         return ::CoCreateInstance (rclsid, 0, dwClsContext, __uuidof(T), (void**) &p);
+#else
+	return S_FALSE;
+#endif
     }
 
     T* p;
@@ -215037,6 +215041,7 @@
 BEGIN_JUCE_NAMESPACE
 
 using namespace jpeglibNamespace;
+using jpeglibNamespace::boolean;
 
 struct JPEGDecodingFailure {};

Bye…


#2

Ok, thanks for that.

I’m happy to add the “using jpeglibNamespace::boolean;” bit, but am surprised that CoCreateInstance doesn’t work… Surely the mingw libraries include that function?


#3

It’s not CoCreateInstance, it is __uuidof() operator

Visual C++ Language Reference
__uuidof Operator

Microsoft Specific

Retrieves the GUID attached to the expression.

#4

Ah, I see. Ok, thanks.


#5

Hi,

You added:

#if ! JUCE_WIN32
 using jpeglibNamespace::boolean;
#endif

This doesn’t work for MinGW:
JUCE_WIN32 is defined for MinGW

Bye


#6

So I guess it’d need to be

?


#7

Correct.


#8

I’m finding more problems than this to build a win executable with qt-creator and gcc4.4 from mingw on a windows machine.
Here are the problems:

  1. <crtdbg.h> and <comutls.h> are not present in mingw include files (including MSVC ones don’t work).

#if JUCE_WIN32
#ifndef GNUC
#include <crtdbg.h>
#include <comutls.h>
#endif
#endif

  1. alloca isn’t defined (used in EdgeTable)… something like this would do

#if JUCE_WIN32
#if defined GNUC
#define alloca __builtin_alloca
#endif
#endif

  1. the WM_APPCOMMAND message isn’t defined in mingw headers. add something like this:

#ifndef WM_APPCOMMAND
#define WM_APPCOMMAND 0x0319
#endif

i will post more as i advance on this.


#9

any advance in this topic??

Cheers…


#10

Can’t remember - this is over a year ago! Try the tip.


#11

From the tip… this should read:

	static juce_wchar* doubleToString (juce_wchar* buffer, int numChars, double n, int numDecPlaces, size_t& len) throw()
	{
		if (numDecPlaces > 0 && n > -1.0e20 && n < 1.0e20)
		{
			juce_wchar* const end = buffer + numChars;
			juce_wchar* t = end;
			int64 v = (int64) (pow (10.0, numDecPlaces) * std::abs (n) + 0.5);
			*--t = (juce_wchar) 0;

			while (numDecPlaces >= 0 || v > 0)
			{
				if (numDecPlaces == 0)
					*--t = getDecimalPoint();

				*--t = (juce_wchar) ('0' + (v % 10));

				v /= 10;
				--numDecPlaces;
			}

			if (n < 0)
				*--t = '-';

			len = end - t - 1;
			return t;
		}
		else
		{
#if JUCE_WINDOWS
  #if (JUCE_MSVC && _MSC_VER <= 1400) || JUCE_MINGW
			len = _snwprintf (buffer, numChars, L"%.9g", n);
  #else
			len = _snwprintf_s (buffer, numChars, _TRUNCATE, L"%.9g", n);
  #endif
#else
			len = swprintf (buffer, numChars, L"%.9g", n);
#endif
			return buffer;
		}
	}
}

a small fix in the ifdefs allowing MINGW to compile here.


#12

Ok, thanks!