[CppAD] building pycppad in Windows

Carlos Christoffersen cechrist at vision.lakeheadu.ca
Sat Jun 22 09:49:29 EDT 2013

Instructions to build the pycppad module with WinPython-32

The following instructions describe how to build the pycppad automatic
differentiation library
(http://www.seanet.com/~bradbell/pycppad/index.htm) to be used with
the 32-bit WinPython (http://code.google.com/p/winpython/). This is
known to work well on 64-bit Windows 7 and 32-bit Windows XP.  A
somewhat similar set of steps with some modifications could possibly
be followed for the 64-bit version, but I have not tried it.

  1. Download and install WinPython-32-bit- If you want to use
  the configuration files included here, install in
  The 32-bit distribution comes with a copy of the MinGW-32 compiler
  that we will use to build the extension. Open the "WinPython Command
  Prompt" to build everything. The PATH variable in that command
  prompt is already set to point to the mingw compiler and the python

  2. Download and install the cppad library:

  Follow the configuration instructions and pass the following options
  to ``cmake``::

    cd cppad2013xxxx
    mkdir c:\local
    mkdir build
    cd build
    cmake -G "MinGW Makefiles" -D cmake_install_prefix=c:\local ..

  Then install the header files as follows::

    mingw32-make install

  (replace ``c:\local`` with a directory of your choice)

  3. Download and build the boost python library: download the latest
  sources for the boost library: 

  In the source directory (assume c:\src\boost_1_53_0) type::

     cd \src\boost_1_53_0
     bootstrap.bat mingw

  Edit the ``project-config.jam`` file as follows (adjust path names
  if needed)::

    import option ; 
    using gcc ;
    option.set keep-going : false ; 
    using python : 2.7 : c:\\WinPython-32bit-\\python-2.7.5 
    	  	 : c:/WinPython-32bit- 
		 : c:/WinPython-32bit- ;

   Now build the library::

     .\b2.exe variant=release link=shared threading=multi python

  4. Download pycppad from

  Edit the top os ``setup.py`` as follows::

    # Directory where CppAD include files are located
    cppad_include_dir        = [ 'c:/local/include' ]
    # Directory where Boost Python library and include files are located
    boost_python_include_dir = [ 'c:/src/boost_1_53_0' ]
    boost_python_lib_dir     = [ 'c:/src/boost_1_53_0/bin.v2/libs/python/build/gcc-mingw-4.6.2/release/threading-multi' ] 
    # Name of the Boost Python library in boost_python_lib_dir.
    boost_python_lib         = [ 'boost_python-mgw46-mt-1_53.dll' ]

  Save the file and build as follows::

    python setup.py build_ext --compiler=mingw32 install

  There is one additional step: copy the boost python library to some
  place that can be found in the ``PATH``::

    copy c:\src\boost_1_53_0\bin.v2\libs\python\build\gcc-mingw-4.6.2\release\threading-multi\libboost_python-mgw46-mt-1_53.dll c:\WinPython-32bit-\python-2.7.5

  After that you should be able to import the library in the python
  interpreter. It should work with IPython Qt Console, Spyder and the
  WinPython Interpreter too.

I have posted a ready-to-use pycppad library to be used with
WinPython-32-bit- at:


To install it open the zip file and put all files in the
``python-2.7.5`` subdirectory of the WinPython installation::

      cd \WinPython-32bit-\python-2.7.5
      unzip c:\Users\user1\Downloads\pycppad-WinPython-32bit-

Carlos Christoffersen
Associate Professor
Department of Electrical Engineering
Lakehead University
955 Oliver Road
Thunder Bay, Ontario P7B 5E1

More information about the CppAD mailing list