Jump to: navigation, search

Windows build instructions

Revision as of 05:38, 8 February 2016 by Steveshoyer (talk | contribs) (Windows build instructions for P-ROC and pyprocgame)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This page contains step-by-step instructions for building libpinproc and pypinproc in Windows. These instructions have been verified to work in Windows XP, Windows Vista, and Windows 7.

Note - You only need to build from source code if you are making code changes or you are making use of the development branches of libpinproc/pypinproc/pyprocgame. All other users can simply download and run the Windows installer from the P-ROC software page. The Windows installer includes the low level USB driver, a firmware update utility, and a pre-built pypinproc python extension so you can start using the pyprocgame python game framework if that interests you.

Tools

  • Download and install MinGW. The easiest way is to use the automated installer mingw-get-inst. Any of the latest versions should work.
    • Note - Be sure to install C and C++ support at the very least.
    • Note - the rest of these notes assume you installed to C:\MinGW. If you installed somewhere else, substitute your path in the instructions below.
  • Add C:\MinGW\bin to your path. (Right click My Computer, select Properties, click on the Advanced tab, click on environment variables, and add C:\MinGW\bin to the PATH variable under System variables. The new path should be reflected when you open a new command prompt).
  • Download and install cmake and add <your-cmake-directory>\bin to your path. Latest version tested: 2.8

libpinproc

  • Download and extract the ftd2xx USB driver for Windows. Latest version tested: 2.08.14, newer version *should* work fine too.
    • copy ftd2xx.lib and ftd2xx.dll from the i386\ directory to C:\MinGW\lib
    • also copy ftd2xx.dll to Windows\System32\ (32-bit) or Windows\SysWOW64\ (64-bit) - this *should* happen automatically when you plug in your P-ROC board, but if you're trying to do off-line development, you might need to do it manually.
    • copy ftd2xx.h to C:\MinGW\include


  • Build yaml-cpp
    • Download and extract yaml-cpp into a directory of your choice. Latest version tested: 0.2.5
    • From the command line, 'cd' into your yaml-cpp directory and run the following commads:
   mkdir bin
   cd bin
   cmake -G "MinGW Makefiles" ..
   mingw32-make
   cmake -DCMAKE_INSTALL_PREFIX:PATH=C:\MinGW -P cmake_install.cmake
    • Note - These commands expect cmake and mingw32-make to be in your path
    • Note - If you want to build a static library instead of a DLL, edit the CMakeLists.txt file in the yaml-cpp directory and change the "set(LIB_TYPE SHARED)" to "set(LIB_TYPE_STATIC)". Then rerun the last two commands from the bin directory.


  • Build libpinproc
    • Download (and extract) libpinproc into a directory of your choice. Note - make sure you select the desired branch to download (either master or dev).
      • Download either by clicking 'Download Sources' or by installing a git client and checking out the repository.
    • From the command line, 'cd' into the libpinproc directory and run the following commands:
   mkdir bin
   cd bin
   cmake -G "MinGW Makefiles" ..
   mingw32-make
   cmake -DCMAKE_INSTALL_PREFIX:PATH=C:\MinGW -P cmake_install.cmake
    • Note - If you want to build a shared library instead of a static one, add "-DLIB_TYPE=SHARED" before the -DEXTRA_INC... on the first cmake line. (3rd command).


  • Build pypinproc - libpinproc Python extension
    • Install Python 2.6 if you don't already have it. Usually it installs to C:\Python2.6\
      • Note - pypinproc requires 32-bit Python, even on 64-bit Windows machines. So please make sure to install the 32-bit version of Python .
      • Create a file in C:\Python2.6\Lib\distutils\ called 'distutils.cfg', and enter the following two lines:
        • [build]
        • compiler=mingw32
    • Download (and extract) pypinproc into a directory of your choice. Note - make sure you select the desired branch to download (either master or dev).
      • Download either by clicking 'Download Sources' or by installing a git client and checking out the repository.
    • From the command line, 'cd' into your pypinproc directory
    • edit setup.py:
      • Make sure the 'include_dirs' line contains <your_path_to_libpinproc>/include (note - use forward slashes instead of backslashes).
      • Make sure the 'library_dirs' line contains 'C:/MinGW/lib' since that's where you put ftd2xx.lib and libpinproc.a (note - use forward slashes instead of backslashes).
      • Change the 'libraries' line to read: (Note - the order of the libraries seems to matter; so copy the line exactly.)
        • libraries = ['pinproc', 'ftd2xx'],
      • Save and quit.
    • Run '\Python2.6\python.exe setup.py install' in the pypinproc directory.
    • This should compile pypinproc and install it into your Python packages directory.
    • NOTE: If the setup script complains about "error: unrecognized command line option '-mno-cygwin'" then the setup script must be modified since newer versions of GCC have dropped the legacy -mno-cygwin option.
      • go to C:\Python26\Lib\distutils\ and open cygwincompiler.py in Notepad or your favorite text editor
      • Edit lines 322-326 to look like this:
   self.set_executables(compiler='gcc -O -Wall',
                            compiler_so='gcc -mdll -O -Wall',
                            compiler_cxx='g++ -O -Wall',
                            linker_exe='gcc',
                            linker_so='%s %s %s'
    • Note that you're only removing the -mno-cygwin option from the argument list.
      • Save the script and rerun '\Python2.6\python.exe setup.py install'