This section of the archives stores flipcode's complete Developer Toolbox collection, featuring a variety of mini-articles and source code contributions from our readers.

 

  How To Compile DirectX Programs With GCC
  Submitted by



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:

Requirements:
  • (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


  • Installation:
  • (1) Copy all DirectX include files (name ****.h) to the GCC include directory (GCCDIR\include).
  • (2) Copy all DirectX import libraries (name lib****.a) to the GCC lib directory (GCCDIR\lib).
  • For DirectX8 (3) Put the line "#define HMONITOR_DECLARED" at the top of the file GCCDIR\include\windef.h
  • (4) Put the line "typedef unsigned int *UINT_PTR;" at the top of the file GCCDIR\include\wtypes.h


  • Usage:
  • 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 "-ldxguid".


  • That's about it.
    Have fun,
    -chris


    The zip file viewer built into the Developer Toolbox made use of the zlib library, as well as the zlibdll source additions.

     

    Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
    Please read our Terms, Conditions, and Privacy information.