Compile DirectX 9 SDK samples and BaseClasses under Visual Studio 2005
I have noticed that there are a lot of complaints about building DX9 projects especially the BaseClasses under example code directory using Visual Studio 2005. I personally also experienced the similar errors. I had a project that compiled perfectly under my DX9 + Visual Studio 2003 (VS7). When I imported the project to my Visual Studio 2005 environment, I suddenly got many compilation errors. After spending some time debugging and searching information from Internet, I finally fixed all those issues. The errors might appear as follows:
…\DirectShow\Samples\C++\DirectShow\BaseClasses\ctlutil.h(278) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Or
c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h(222) : error C2146: syntax error : missing ';' before identifier 'PVOID64'
Anyway, to my understanding, the above problems have several root causes. First, the include files are messed up when importing the DX9 projects under VS2005. Note that in VS2005 there are two places where you configure the include directories. The first one is when you right click the project properties and select “Configuration Properties” and then choose C/C++ -> general ->Additional Include directories. The other place to add include directories is to use “Tools ->Options ->Project and Solutions ->VC++ directories ->select include files from the top-right list box”. Note that project include directories will overwrite the tools-options include directories. In my platform, my DX9 is installed under C:\DXSDK\ and my VS2005 is installed under “Program Files” on C drive.
My project include directories are configured as:
- “.,..\..\..\..\include”
My tools options include directories are configured as:
- $(VCInstallDir)include
- $(VCInstallDir)PlatformSDK\include
- $(VCInstallDir)atlmfc\include
- $(FrameworkSDKDir)include
- C:\DXSDK\Include
- C:\DXSDK\Samples\C++\DirectShow\BaseClasses
Note that the above include order is very important because the project needs to include platform SDK include files first and then DX’s own include files.
There will be some errors even using the above correct include order. For example, the compiler might complain that the “PVOID64” definition has problems. The fix for that issue is to add the following line at line 220 in winnt.h file.
#define POINTER_64 __ptr64
There will be other errors such as “g_dwLastRefresh” does not have a type, or “Count” is not defined, etc. These are can be easily fixed by just adding data type definitions. The fix for ctlutil.h file is to change the following code from:
operator=(LONG);
to
COARefTime& operator=(LONG);
After these minor fixes, the BaseClasses under VS2005 should compile OK.

0 Comments:
Post a Comment
<< Home