Tuesday 15 July 2014

Python binding with IDE

How brilliant would it be, if Python binding can be achieved using IDE that aims to simplify software development process.
Am sure you would love it when you are able to configure your IDE to use bjam for its custom building process.
The IDE am gonna use here is Microsoft Visual Studio.Net 2012 ( you can use any IDE and configure it appropriately with the below steps).

So lets start!

Configure Visual C++ Project to use Boost.Build

  1. As Boost uses it own Build system - bjam, you will have to start with an Empty C++ Project
    (File->New->Project Select Under 'Visual C++', select 'Empty Project')
  2. And new text document and rename it to Jamroot (Note :  not Jamroot.txt)  Copy the entire Jamroot file contents from the .../example/tutorial folder here. Make sure the appropriate changes are made according to your project as mentioned in my previous post)
  3. Add another text document and rename it into boost-build.jam It just needs to contain this line,
    boost-build "C:/Boost/1.55.0/tools/build/v2";
  4. Create a new C++ file, say hello.cpp Copy the contents of the already existing hello.cpp from .../examples/tutorial.
  5. Open Project properties page. Right-click Project, select Properties. Make the following changes in that window 
  • Under 'General' :
    Configuration Type : Change to Static Library(.lib) ( Really have no idea why we have to do this, but the other Configuration types cause unnecessary link errors , Dll worled for me though :) )
  • Under 'VC++ Directories' :
    Include Directories, add C:\Boost\1.55.0;C:\Python27\include;
    Library Directories, add C:\Boost\1.55.0\stage\lib;C:\Python27\libs;
    ( Note : Add appropriate file location in your system )

  • Under 'Custom Build Step' :
    Command Line : bjam
    Outputs : .pyd
Finally, build your project. If you have done everything correctly, you should be able to Build it successfully without errors and find a *.pyd file in your project root folder.


Congratulations! You have built your project successfully with Visual Studio. The steps are quite similar for any IDE.


Reference :


[1]   http://pythonthusiast.pythonblogs.com/230_pythonthusiast/archive/1335_pycocos2d-x__how_to_properly_setup_boostpython_in_your_visual_c_2012_project.html


No comments:

Post a Comment