Build Simulation Library for Windows on Debian x86_64 host

This page describes the simplest way to cross-build the OpenVisualizer simulation module for a Windows host from a Debian Linux x86_64 (64-bit) host. The cross-build supports both 32-bit (x86) and 64-bit (x86_64) Windows hosts. We base the build on the MinGW-w64 toolchain. We also incorporated the script from the SCons CrossCompilingMingw page as 'site_scons/site_tools/crossMingw64.py'.

To get started, first install the mingw-w64 distro package.

Get the Windows Python DLL

Rather than cross-compile Python, as we did for the x86-linux cross-build, we simply extract the shared library and include files from Python's Windows installer. Alternatively, we could build from source using the python-a-mingw-us project.

To extract from the installer:

  1. Download the latest MSI for x86 or x86_64 from the Python download page.
  2. Install the 7Zip distro package.
  3. Use 7Zip to extract the MSI contents, and then extract the contents of the 'python' file. For example, for x86:
       $ 7z e ../python-2.7.6.msi python && 7z e python *.h python*.dll
  4. Copy the python DLL and header files into a single convenient directory so they may be referenced during the build. Don't create a separate 'include' directory.

Build the simulation module

With the Python library and headers in place, we now can build the simulation module. We must specify the architecture for the build, and the location of the extracted Python files. The example command line below provides an x86_64 build, where the Python files for that architecture were placed in ~/opt/python-win64.

$ scons board=python toolchain=gcc simhost=amd64-windows simhostpy=~/opt/python-win64 oos_openwsn

The resulting library, 'oos_openwsn.pyd', is in the 'firmware/openos/projects/common' directory.