Thursday, December 11, 2014

How to create python extended libraries using Boost on Windows

    Of course you need Visual C++ to execute all of these steps, I recommend using Visual Studio Express Edition

    1. Download Boost library and create bjam using bootstrap.bat script file
    2. If you use older Boost (prior to version 1.57.0) you have to open user-config.jam on tools/build/v2/, and type following section
       
      using python : 3.4 : C:\\Python34 : C:\\Python34\\include : C:\\Python34\\libs;


      It will depend on the Python version you installed on your system.And again, if you use Boost library version 1.57.0 you don't have to edit the user-config.jam.
       
    3. Build boost library with python support ( --with-python)
    4. Open Up your Visual Studio IDE, create new dll project
    5. Copy the simple program that includes in python boost documentation
    6. Open property page of your project
    7. Change Target Extension  into .pyd
    8. Change Target Name match with your extension module
    9. Add include directory with python include directory and your new installed boost library
    10. Add the library directory with your python libs path and with your boost's libs path
    11. Add additional dependency with python34.lib , DO NOT use python3.lib, it might caused troubled when loading library during python execution
    12. Build and test the library
    13. If there is troubled while loading your pyd file, it might need some "dll,  track its 
      dependency using tools which you can download from http://dependencywalker.com/

    NOTE:
    Add this line in your source codes project  if you configure your project using static library
    #define BOOST_PYTHON_STATIC_LIB


    This is the boost python library build command
    $ bjam --build-dir=D:\\Boost\\BuildDir --build-type=complete --with-python link=static threading=multi stage

    Monday, December 1, 2014

    A physicist, an engineer and a programmer

    A physicist, an engineer and a programmer were in a car driving over a steep alpine pass when the brakes failed. The car was getting faster and faster, they were struggling to get round the corners and once or twice only the feeble crash barrier saved them from crashing down the side of the mountain. They were sure they were all going to die, when suddenly they spotted an escape lane. They pulled into the escape lane, and came safely to a halt.
    The physicist said "We need to model the friction in the brake pads and the resultant temperature rise, see if we can work out why they failed".
    The engineer said "I think I've got a few spanners in the back. I'll take a look and see if I can work out what's wrong".
    The programmer said "Why don't we get going again and see if it's reproducible?"