Compiling DX9 With MinGW
Before we start, know that this has not been extensively tested yet. I have not been able to get dx8 working with Irrlicht yet, but if I am able to do so easily I will be sure to update this tutorial.
Get DirectX SDK
You can download the latest DirectX SDK here.
Installing DirectX SDK
After the 500MB SDK is finally downloaded, we need to install it. And contrary to popular belief you only need a small portion of the SDK to actually build Irrlicht with DX9 support. Install wherever you like, just place it somewhere meaningful. Below are the settings you should need.
- Install DirectX Runtime
- Developer Runtime Support (only if you want to compile against a debug build of DirectX)
- DirectX Headers and Libs
- DirectX Redistributable Files (only if you want to include DirectX install with your app)
Now make sure you know the path to the install folder, default is C:\Program Files\Microsoft DirectX SDK (March 2009) If your like me and don't like the bloat, you can copy the Include and Lib folders somewhere else for better organization, and remove the SDK after that. All Irrlicht will care about is Include and Lib.
Setting up Code::Blocks
If you are not using Code::Blocks you will have to set the command line args yourself, as I have not used MinGW that way.
Now there are a lot of build targets in here, so select one of the Win32 ones (preferably which one you want to build). After we are done you are able to copy these setting to the other build targets if you want.
- IRR_COMPILE_WITH_DX9_DEV_PACK (more about this later)
Now onto the Linker setting tab! We need to tell the compiler that we want to link to DirectX9 so add another Link Library
- d3dx9 (d3dx9d for debug build of DirectX)
Go over to the Search Directories tab next. On the Compiler tab add this, and move it to the top of the list
- C:\Program Files\Microsoft DirectX SDK (March 2009)\Include (or click the ... to browse for it easily)
Next is the Linker tab, add the Lib folder for your system. Only x86 was tested for this.
- C:\Program Files\Microsoft DirectX (March 2009)\Lib\x86
Redo these steps for any other build targets you want to build with DirectX support. Then click OK and move on!
This step is not needed for d3dx9_40 and _42, looks like it might just be for _41.
Around line 115 there should be this #if statement:
#if defined(_IRR_WINDOWS_API_) && (!defined(__GNUC__) || defined(IRR_COMPILE_WITH_DX9_DEV_PACK))
Remember we defined IRR_COMPILE_WITH_DX9_DEV_PACK earlier, however, the actual DevPack is for DevC++. We are not using that but we need to get around the !defined(__GNUC__) statement.
#if defined(_IRR_WINDOWS_API_) && (!defined(__GNUC__) || defined(IRR_COMPILE_WITH_DX9_DEV_PACK)) //! Only define _IRR_COMPILE_WITH_DIRECT3D_8_ if you have an appropriate DXSDK, e.g. Summer 2004 //#define _IRR_COMPILE_WITH_DIRECT3D_8_ #define _IRR_COMPILE_WITH_DIRECT3D_9_ #define DECLSPEC_DEPRECATED #endif
Make sure you select the build target you added the define and search paths to, and build Irrlicht with DirectX9 support using MinGW!
C::B MinGW Irrlicht DirectX ----- --------- ---------- ---------- 8.02 3.15.2 1.5 40 (Nov08) 8.02 3.15.2 1.5 41 (Mar09) 8.02 3.15.2 1.6(r2491) 41 (Mar09) r5716 GCC 4.4.0 1.5.1 40 (Nov08) r5731 3.15.2 1.6 (sdk) 42 (Aug09) 8.02 3.14 1.7 (sdk) 42 (Aug09)
If you have any questions or comments about this tutorial please feel free to email me. If this does work for you and have other configs that work, please email them to me or add to the wiki.