1

I have searched and searched and found no way to get directX to compile under MingW, I've seen others success and tried to replicate it to no avail. I've already read this similar question and it didn't help so please don't direct me to it: How to compile a DirectX 11 app in MinGW.

I've been trying to get MingW to cooperate with directX for a long time now, here is a list of my failed attempts and what I've read worked for others:

  • Download MSVC headers and have MingW use them
  • Download MingW-W64 and use it to compile
  • Download Reubens MingW-W64 and use it to compile
  • Download the most up to date MingW compiler and use it
  • Download TDM-GCC and use it.
  • mix compiler headers in a desperate attempt to make errors go away

I heard that I should be able to at least get to fail at the linker phase if I just dump the directX headers into the appropriate place, but I'm getting syntax errors left and right even after I did that (granted the bulk of them went away.) Each compiler ends up with its own unique errors, failing at different points but appearently succeeding in places where the others fail at some points. What is going on? Why does perfectly valid code (all written by microsoft) suddenly fail to compile when handled by any other compiler?

Community
  • 1
  • 1
user2462027
  • 323
  • 3
  • 16
  • "perfectly valid code (all written by microsoft)". (Haha. sorry.) Visual Studio is doing it´s own thing since it exists. Many standard language features are lacking or poorly implemented, and on the contrary MS introduced a ton of new keywords etc. which are incompatible with standard C/C++ (and often incompatible with every major compiler except VS itself). Not sayin that VS is bad, but "following standards" is something MS can´t do well. – deviantfan Sep 23 '14 at 21:37
  • Specifically, which DirectX tutorial sample are you trying to compile? – Ross Ridge Sep 24 '14 at 03:12
  • @RossRidge I'm trying to compile basicHLSL – user2462027 Sep 25 '14 at 14:38

1 Answers1

4

Unfortunately the samples include with the DirectX June 2010 SDK are far from "perfect valid code". They use a number of extensions specific to Microsoft's compiler.

Before I gave up on it as being essentially hopeless, I found the following Microsoft's specific dependencies when trying to compile the sample in Samples\C++\Direct3D\BasicHLSL:

  • the __noop intrinsic
  • the macros __min and __max
  • various "safe" versions of standard functions, like wsprintf_s and strcpy_s
  • non-standard pre-processor token pasting
  • allowing goto across variable initialization
  • the __uuidof operator

There are also problems with Microsoft's DirectX headers that I haven't mentioned, like being dependent on Microsoft's SAL annotation macros. Arguably though this a failing of MinGW for not having compatible versions of these DirectX headers.

Some of these problems are relatively easy to work around. Others are more difficult and would require rewriting the incompatible parts of the sample. There are also likely to be more Microsoft dependencies in the sample that I didn't discover.

The bottom line is that there's no way to compile the samples included with the DirectX SDK with MinGW or any other port of GCC without first modifying to the samples and the DXUT framework to make them more portable.

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
  • Note you may have better luck using the latest versions of these samples on [MSDN Code Gallery](http://blogs.msdn.com/b/chuckw/archive/2013/09/20/directx-sdk-samples-catalog.aspx) which use a cleaned up [DXUT](http://go.microsoft.com/fwlink/?LinkId=320437). I still make use of the Safer CRT functions, SAL2 annotations, and ``-_uuidof``. That said, you can easily define all SAL2 annotation macros as 'blank' (which is what the SAL headers in the Windows SDK already do if you are not using /analyze), use macros for Safer CRT, and then deal with ``__uuidof``. Or just use VS Express. – Chuck Walbourn Sep 27 '14 at 18:09