## MINGW32 AND DIRECT X

The original header files seems to work so the only problem is to update the lib files that means creating one static and some import libraries. Here is how I did it for directx 7 and how you can update it for common versions.

1. Copy all DEFINE_GUID definitions from the directx header files to dxguid.c this will become a static library and replace dxguid.lib from Microsoft. In dxguid.c should also the constants from dinput.h be defined.

2. Create the import libs I tried to let reimp do this but it did not work all the way but running reimp -s > file.def gave me the symbols with parameter size. You will need to edit the def files slightly with an EXPORTS on top and perhaps deleting irrelevant garbage.

3. I created a makefile this file must perhaps be updated in the future.

4. Run make and place the libs in the compiler lib directory.

As far as I know do mingw32 support all of directx in both C and C++ with full COM support. My libs can of course miss a lot and the data for the new Mouse2 is probably wrong since I took it after some inspecting of dinput.lib with a dump tool. :-)
Some comments about using directx with mingw32:

- C++ programs must be compiled with the -fvtable-thunks switch. Don't worry gcc will tell you if you forgot to use it. about 1000 times :-)
- d3d has a bad reputation I and many with me prefer open GL instead
- WINNT is defined despite I am running win95 this created problems with ddraw.h so I put an undef WINNT at top of it no guarantees that this is the way to solve it
- a lot of warnings about redefinition I haven't checked out why
- if you are compiling the examples from Microsoft's SDK (available at MSDN) don't forget to compile the .rc file with windres and link with it. For example "windres app.rc appres.o" creates appres.o and this file should be linked like the other .o files.
- windres can not compile all .rc files but in the DEBUG directory is it a precompiled .res file that windres can use. ("windres app.res appres.o")
- an alternative can be to use another resource compiler like the one from Borland to create the .res file
- some SDK examples can not be compiled because of incomplete header files but if you download the Borland compiler do you also get a more complete set of headers. If something is missing in the mingw32 headers can you search for it in the Borland headers (MS original) and update the mingw32 files.
- in many cases is it better to use allegro instead of directx directly (easier and portable) the windows version of allegro is using directx
- MSVC accepts non ANSI C++ this is common in the MSDN examples
- if an SDK example does not work properly is it probably because of some MSVC hack, do not assume something else unless you can compile and link with -Walll without getting any warnings

OK, enough of advises here is the dxlibs you must get the headers from Microsoft.

Microsoft SDK for directx (the full SDK is recommended but you only need to download the headers)
MS SDK examples (and here is some simple makefiles I have done for some of the examples)
Peter Hawkins original dirext 5.0 port (my directx work is based on his port but the limitations is history)
John Fortins 6.0 port with the donuts example (use this makefile instead if you want to compile the donuts example on his page)

If you are interested in directx programming do I think that it would be great if you created a page with info and makefiles for the SDK examples with mingw32. That could certainly help a lot of people!

back to main page