Friday, March 07, 2008

When mixing managed code with native C++ code ...

In the code generation section: there are few different options for the output runtime. The only supported CRT model with /CLR is /MD, i.e. multi-threaded DLL. There is a mixed code in my project since some are managed and some are native C++. In the earlier version of Visual Studio .Net IDE, I think there is an option that allows users to set “use the managed code”. But in VS2005, the option is gone. So, we need to be careful that if we want to use mixed code we will need to use both /MD and /clr. My command line options are:

/O2 /D "WIN32" /D "NDEBUG" /D "_VC80_UPGRADE=0x0710" /D
"_MBCS" /FD /EHa /MD /Fo"Release\\" /Fd"Release\vc80.pdb"
/W3 /nologo /c /Zi /clr:oldSyntax /TP /errorReport:prompt


Microsoft MSDN page for /CLR restrictions:

http://msdn2.microsoft.com/en-us/library/2kzt1wy3.aspx

Visual Studio 2005 + DirectX 9

I recently work on a Visual C++ project compiled under Visual Studio 2005 IDE. The project uses the old DirectDraw features that are still being supported in DirectX 9 SDK That SDK was released on 12/19/2002. I don’t like the later SDK updates since my favorite GraphEdit is missing in the utilities.

Microsoft DirectX 9 SDK

http://www.microsoft.com/downloads/details.aspx?familyid=124552ff-8363-47fd-8f3b-36c226e04c85&displaylang=en

Anyway, the first thing I did is to install VS2005 but it failed at first. It turned out the installation program has problem handling a directory containing a white space. Ha Ha! Funny!

After the installation of the VS2005, I then installed DirectX 9 SDK. Everything went very smoothly. I remember 5 years ago when I installed the DirectX 9 on my XP, it crashed on my Dell machine. It was a blue screen crash. My fix back then is to enter the safe mode and then enable “release mode” in DirectX. I guess now XP with the latest service pack 2 does get stable.

Compiling the project also gave me a small headache. The first error I got is “ddraw.h” cannot be found. After I added the DirectX include directory into the project properties, I still got some strange errors like this:

C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(222) : error C2146: syntax error : missing ';' before identifier 'PVOID64'

Then after spending some time playing with all the settings, I found the actual fix is to use “tools” --> “options” --> ”VC++ Directories” --> ”include files” (top right drop down list).

I need to include the “C:\DXSDK\Include” as the last entry. And then I will have to add “C:\DXSDK\Lib” in the “library files”. That fixed everything for me …