How To Compile DirectX Programs With GCC|
This Tip of the day is aimed at setting up GCC so you can create DirectX
programs with it. Since I did this quite a couple of times now here is how
to do it:
(1) GCC. Suppose you have a working version of either MinGW32 or Dec-C++
installed. MinGW32 is a straightforward port (command-line only) of GCC for
Windows (http://www.mingw.org), Dev-C++ is a free graphical IDE that uses
GCC as compiler engine (http://www.bloodshed.net). I will refer to GCCDIR
where your have GCC installed for example c:\mingw or c:\devc.
(2) The DirectX SDK either version 7 or version 8. At the very minimum you
need the DirectX include files, but I don't know if you can get them
separately from Microsoft.
(3) Import libraries converted to the GCC format. Go to the following page,
it explains how to do it yourself or get some precompiled ones (dx7libs.zip
or dx8libs.zip): http://sites.netscape.net/ptrpck/directx.htm
(1) Copy all DirectX include files (name ****.h) to the GCC include
(2) Copy all DirectX import libraries (name lib****.a) to the GCC lib
(3) Put the line "#define HMONITOR_DECLARED" at the top of the file
(4) Put the line "typedef unsigned int *UINT_PTR;" at the top of the file
Write DirectX-Code normally. Then when it comes to compiling, for any
#include <****.h> that you did in the source files put the linker option
"-l****" into the command line. For instance, #include <d3dim.h> and link
with "-ld3dim". If you refer to GUID in your code, also link with
That's about it.
The zip file viewer built into the Developer Toolbox made use
of the zlib library, as well as the zlibdll source additions.