ctypes code generator for cheapskates

6 AM July 14, 2005

Thomas Heller’s ctypes module is turning out to be very useful for calling strange Windows SDK APIs. Despite not having Visual Studio (marked as required by the documentation) I’ve just kind-of installed the custom gccxml used by ctypes, and am recording the steps I took to do it, before I forget how.

  1. First, download and install Microsoft’s Platform SDK, and Visual C++ Studio 2003
  1. Download the gccxml installer executable from SourceForge. Run it.
  1. Now we need to trick gccxml into thinking that you have Visual Studio. Start regedit, go to HKLM\SOFTWARE\Microsoft\VisualStudio\7.1, and add a new string value named “InstallDir”. Set its value to C:\Program Files\Microsoft Visual C++ Toolkit 2003 or wherever it was that you installed the C++ compiler.
  1. Make a directory named vc7 two directories above your Visual C++ installation. For me, this was C:\vc7.
  1. Copy the contents of the compiler’s include directory to C:\vc7\include.
  1. Copy the contents of the Platform SDK‘s include directory to C:\vc7\PlatforSDK\include.
  1. Open a command prompt in C:\Program Files\gccxml\install (assuming you installed gccxml to its default directory.)
  1. Run vcInstall . ”\Program Files\gccxml\bin”
  1. Watch as vcInstall runs “patch” twice.

Now to find out whether or not it works enough to be usable…

Update Yes, it is usable, but gccxml seems chokes on the definition of the __nothrow macro, so I have to add -D—nothrow to the h2xml.py command line.

Update 2 Or alternatively, use the h2xml.cfg file, just like the doco says :).

By alang | # | Comments (0)
(Posted to Software Development and Python)
© 2003-2006 Alan Green