# MinGW report

**URL:** <https://forum.juce.com/t/mingw-report/4088>\
**Category:** Windows\
**Created:** [July 9, 2009, 10:21am UTC](https://forum.juce.com/t/mingw-report/4088 "2009-07-09T10:21:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![iradic](https://avatars.discourse-cdn.com/v4/letter/i/85f322/32.png) [@iradic](https://forum.juce.com/u/iradic)\
**Post date:** [July 9, 2009, 10:21am UTC](https://forum.juce.com/t/mingw-report/4088/1 "2009-07-09T10:21:26Z")

</div>

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:

```auto
--- /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…

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 9, 2009, 1:02pm UTC](https://forum.juce.com/t/mingw-report/4088/2 "2009-07-09T13:02:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![iradic](https://avatars.discourse-cdn.com/v4/letter/i/85f322/32.png) [@iradic](https://forum.juce.com/u/iradic)\
**Post date:** [July 9, 2009, 1:38pm UTC](https://forum.juce.com/t/mingw-report/4088/3 "2009-07-09T13:38:13Z")

</div>

It’s not CoCreateInstance, it is \_\_uuidof() operator

```auto
Visual C++ Language Reference
__uuidof Operator

Microsoft Specific

Retrieves the GUID attached to the expression.
```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 9, 2009, 3:20pm UTC](https://forum.juce.com/t/mingw-report/4088/4 "2009-07-09T15:20:56Z")

</div>

Ah, I see. Ok, thanks.

---

<div class="post-metadata">

**Author:** ![iradic](https://avatars.discourse-cdn.com/v4/letter/i/85f322/32.png) [@iradic](https://forum.juce.com/u/iradic)\
**Post date:** [October 3, 2009, 8:08pm UTC](https://forum.juce.com/t/mingw-report/4088/5 "2009-10-03T20:08:41Z")

</div>

Hi,

You added:

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

This doesn’t work for MinGW:  
JUCE\_WIN32 is defined for MinGW

Bye

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [October 5, 2009, 1:45pm UTC](https://forum.juce.com/t/mingw-report/4088/6 "2009-10-05T13:45:29Z")

</div>

So I guess it’d need to be

```auto
#if ! JUCE_MSVC
```

?

---

<div class="post-metadata">

**Author:** ![iradic](https://avatars.discourse-cdn.com/v4/letter/i/85f322/32.png) [@iradic](https://forum.juce.com/u/iradic)\
**Post date:** [October 5, 2009, 2:55pm UTC](https://forum.juce.com/t/mingw-report/4088/7 "2009-10-05T14:55:11Z")

</div>

Correct.

---

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [January 9, 2010, 5:52pm UTC](https://forum.juce.com/t/mingw-report/4088/8 "2010-01-09T17:52:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Fuentes](https://avatars.discourse-cdn.com/v4/letter/f/e9bcb4/32.png) [@Fuentes](https://forum.juce.com/u/Fuentes)\
**Post date:** [April 22, 2010, 12:28am UTC](https://forum.juce.com/t/mingw-report/4088/9 "2010-04-22T00:28:56Z")

</div>

any advance in this topic??

Cheers…

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 22, 2010, 9:39am UTC](https://forum.juce.com/t/mingw-report/4088/10 "2010-04-22T09:39:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [November 3, 2010, 10:45am UTC](https://forum.juce.com/t/mingw-report/4088/11 "2010-11-03T10:45:27Z")

</div>

From the tip… this should read:

```auto
	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.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 3, 2010, 10:58am UTC](https://forum.juce.com/t/mingw-report/4088/12 "2010-11-03T10:58:39Z")

</div>

Ok, thanks!
