Panda compiling under Windows7 using latest PlatformSDK

OK, I just tried to compile multitouch-enabling Panda code on Windows7, and ran into a few issues. I guess it won’t be of much use to most people, since the manual and several forum posts already deal about that stuff. However, I thought I’d still post about the procedure I followed : it shouldn’t be much of an annoyance to anybody, and might even be of some help to other clueless people in the future??

Vincent

This is how I compiled the then latest Panda code (06/29/10) on Windows7 using the latest Platform SDK (v7.1) :

1/ Installing MSVC compiler

As stated in the manual/website : since an archive containing third party tools built against VS2008 is available, it is easiest to use VS2008 to build Panda (VS2010+ would probably require rebuilding dependencies).

Make sure you’re installing the SP1. Or if VC++ 2008 or VC Express 2008 is already installed, upgrade it to SP1 (not necessarily that easy to find, since MS is pushing the 2010 edition ahead, but it is still available from tinyurl.com/2w4k53a)

Otherwise, you might get errors such as :

[ 32%] Linking dynamic library built/bin/libpanda.dll
fatal error C1900: IL mismatch between 'P1' version '20080116' and 'P2' version '20070207'

(see [makepanda libpanda.dll mistmatch error while building))

2/ Installing Platform SDK

In order to compile Windows specific code the SDK must be installed. Depending on your needs I guess you don’t have to install the latest SDK. I personnally installed the latest (v7.1), since I run Windows7 and want the multitouch capability enabled.

3/ Set current SDK version (if needed)

You can check the current version of the SDK by printing the value of the WindowsSdkDir envvar from the VS command prompt, or by looking up its value in the Macros window of the IDE.

In my case:

Setting environment for using Microsoft Visual Studio 2008 x86 tools.

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>echo %WindowsSdkDir%
C:\Program Files\Microsoft SDKs\Windows\v7.1\

However, VS wasn’t using the right SDK at first. I guess that’s because I installed the SDK before VS2008 SP1 (resulting in the current SDK version being v6.0A, when I actually wanted multitouch enabling v7.1 to be current).

I had a bit of a trouble figuring out how to tell VS to use the right version of the SDK. Not too sure whether installing the SDK after VS fixes the problem? Anyway, I ended up typing the following command from the ‘setup’ directory of the SDK I wanted to make current :

WindowsSdkVer.exe -version:v7.1

(as explained in great detail here: tinyurl.com/35fnrzh)

If all worked as intended, Visual Studio should now use the desired SDK.

4/ Retrieve Panda source and dependencies

Retrieve code base from CVS or Panda website.
Make sure third party tools are included in the distribution, or retrieve them from Panda website.

If compiling on a 64 bit processor architecture, makepanda\makepanda.bat looks for a thirdparty\win-python-x64 directory. I renamed win-python to win-python-x64 and it worked fine.

5/ Update compilation scripts (if needed)

In my case, compilation scripts were not as up to date as I had wished, and it took me a while to understand what was going on.

Editing makepanda.py

First off, to enable multitouch the /DPANDA_WIN7 symbol must be defined. This is done in makepanda.py in the CompileCxx function, by checking a registry key :

platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.0", "InstallationFolder") 	
if platsdk and os.path.isdir(platsdk):
    cmd += "/DPANDA_WIN7 /DWINVER=0x0601 "

However, this wouldn’t work in my case since I had installed v7.1 of the SDK. Instead changed the script to something like :

platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1", "InstallationFolder")
if not platsdk:
    platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.0A", "InstallationFolder") 	
if not platsdk:
    platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.0", "InstallationFolder") 	
if platsdk and os.path.isdir(platsdk):
    cmd += "/DPANDA_WIN7 /DWINVER=0x0601 "

Now Panda support of Win7 multitouch would be enabled, but code dealing with touched wouldn’t compile :

windisplay_composite.cxx
c:\panda_source\panda\src\windisplay\winGraphicsWindow.h(198) : error C2146: syntax error : missing ';' before '_touches' identifier
...

This is because the wrong SDK version would be detected by the makepandacore.py script

Editing makepandacore.py

In my case, the SdkLocateMSPlatform function had to be edited as well in order to look for the latest SDK. I fixed it to something like this:

if (sys.platform != "win32"): return
    platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1", "InstallationFolder")
    if not platsdk:
        platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.0A", "InstallationFolder")        
    if not platsdk:
        platsdk = GetRegistryKey("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.0", "InstallationFolder")        
    if (platsdk):
        if os.path.isdir(platsdk):
            print "Windows 7 SDK detected. Enabling special features (multi-touch)."
        else:
            platsdk = 0
...

And that’s it, the project went on to compile successfully after this (even though it did stop at some point when compiling egg utility stuff. Trying again went on to compile everything that was left, strange…)

HTH

Hello,

I found that define environment variable PROCESSOR_ARCHITECTURE = x86 on console is enough to force win32 compilation on windows 7 64 bits OS before using makepanda.

best regards,