Sherman3D
Google  
Web Sherman3D    
Getting DirectX 8.1 to work with Dev-C++ 4.9.8.4
Use this free C++ compiler to begin your journey.
on Tuesday 31 May 2005
by Sherman Chin author list print the content item
in article > C++ Programming

Need a free C++ compiler? Dev-C++ 4.9.8.4 is for you but it comes with some hiccups when using it with DirectX 8.1. This short tutorial will help you iron out the bugs in this great free C++ compiler.

I have noticed that many people would like to know how to use DirectX with Dev-C++ because the beta version of Dev-C++ does not seem to work with DirectX very well until you do some tweaking and the official Dev-C++ site itself does not provide much help. So, I will write about how to get the free Dev-C++ compiler (http://www.bloodshed.net/dev/devcpp.html) to work with DirectX 8.1 and thus, provide the user with a major tool that is needed to code state-of-the-art games . Now, even our game engine as seen in the archive section is fully compilable by Dev-C++ 4.9.8.4. Without further ado, here are the steps to get it to work:

1) Install Dev-C++

2) Use the "Check for Updates/Packages" option in the Tools menu.

3) Download the DirectX9 package (which also includes DirectX 8.1)

4) Select the "Project Options" item from the Project menu. Click on the Parameters tab.

5) In the "Linker" section, click on "Add Library or Object" and add the necessary library files for DirectX. Here is what my list looks like:

-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32

../../../Dev-Cpp/lib/libdsound.a

../../../Dev-Cpp/lib/libdxguid.a

../../../Dev-Cpp/lib/libd3d8.a

../../../Dev-Cpp/lib/libd3dx8d.a

../../../Dev-Cpp/lib/libd3dxof.a

../../../Dev-Cpp/lib/libdplayx.a

../../../Dev-Cpp/lib/libwinmm.a

../../../Dev-Cpp/lib/libdxapi.a

../../../Dev-Cpp/lib/libwsock32.a

../../../Dev-Cpp/lib/libdinput8.a

../../../Dev-Cpp/lib/dinput.lib

../../../Dev-Cpp/lib/strmiids.lib

As you can see, I am using Direct3D, DirectSound, DirectPlay, DirectInput and DirectShow. There are a few other necessary Windows libraries as well. I also added dinput.lib from the Microsoft DirectX 8.1 SDK (download it from Microsoft's site) because the one included with Dev-C++ (libdinput.a) seems to be missing some required data formats. The strmiids.lib, a DirectShow library for playing cutscenes, is not present in Dev-C++ so I added it from the DirectX 8.1 SDK as well.

6) You are bound to run into compile time errors as the *.a DirectX library files that come with Dev-C++ have some typo errors in them. They are usually quite easy to fix though. Here is an example:

Error message: something or other already defined in example.h

Reason: #ifdef _EXAMPLE_

Correction: #ifdef _EXAMPLE_H

Here are the corrections to some of the less obvious typos:

In dxfile.h, delete the last line.

In dmdls.h, change #ifndef MAKE_FOURCC to #ifndef MAKEFOURCC

In dmdls.h, change WLOOP[1] to Wloop[1];

In strmif.h, change #ifndef _WINGDI_ to #ifndef _WINGDI_H

7) The biggest problem for me was getting DirectShow to work. First of all, comment out all the VMR stuff in strmif.h. I seem to get a GUID conflict if I don't. So just comment out lines 20551-20556, 28733-28759, 28759 till 28945. It is going to be a tedious process as there are many /**/ in between and you need to do a // for each line lest you miss out one of those #endif's like I originally did >_<.

8) Another DirectShow problem is that you need to include atlbase.h for automatic conversions from char to wchar but Dev-C++ doesn't come with atlbase.h. I did the filename conversion manually using a Win32 function. Replace

wcscpy(wFileName, lpszMedia);

(the function that is used by the DirectShow examples in the SDK) with

MultiByteToWideChar (

CP_ACP , // code page 

MB_PRECOMPOSED, // character-type options 

lpszMedia, // address of string to map 

-1, // number of characters in string 

wFileName, // address of wide-character buffer 

MAX_PATH // size of buffer 

);



9) Dev-C++ doesn't seem to support the allocation of memory space with the "new" command using a variable for the size of memory to allocate. So, if you have something like this:

m_Polygons = new sPolygon[m_NumPolygons]();

Replace it with:

(void*)m_Polygons = malloc(m_NumPolygons*sizeof(sPolygon));

10) Dev-C++ uses the debug libraries of DirectX so please put d3dx8d.dll (which can be found in the DLL subdirectory of Dev-C++) in your program's directory when you distribute it.

11) If you are using Windows resource files (*.rc), make sure to include "windows.h" in the resource file itself and remove any reference to "afxres.h". Open the resource header file, "resource.h" and write a definition for IDC_STATIC in the list.

There might be some other minor complications when using Dev-C++ with DirectX 8.1 so please post your questions at http://forum.Sherman3D.com and I will try to help the best I can.

[Update 31 May 2005] I know some people are still having problems following my short tutorial above so I have decided to upload my entire Dev-CPP directory. It can be found here:
http://www.Sherman3D.com/Sherman3D/download.php?view.22
Depending on where you copied the downloaded directory to, please remember to change the directory locations accordingly in Step 5: In the "Linker" section, click on "Add Library or Object" and add the necessary library files for DirectX.

If you are wondering why I have not updated the tutorial to for DirectX 9 support, please note that Dev-CPP already comes with a plugin for DirectX 9. Besides that, I am pretty sure that there are people who would prefer to compile for DirectX 8.1 because DirectX 9 is backward compatible (meaning that DirectX 8.1 compiled programs will run on DirectX 9) and DirectX 8.1 comes pre-installed with Windows XP so users need not bother downloading the huge DirectX 9 runtime.
Link to us
Link to us
Warning!
Stats Logging plugin has to be installed for this to work
Welcome
Username or Email:

Password:




[ ]


































Copyright © 2003-2012
Sherman3D

All intellectual property and graphics are strictly protected by Sherman3D.

Please do not redistribute without prior consent.

Thank you.