Tutorial?

The aim of this tutorial is to guide you with the steps required to embed python code into c++ code using Microsoft Visual Studio 2010.

Please note that:

Okay, here are the steps.

Please modify the contents according to your version of Visual Studio and Python.

This will compile both static and shared libraries and install them to the specified path. Please note that this operation takes a lot of time (more or less around one hour), a lot of memory and a lot of disk space. Please make sure to close all unnecessary programs to avoid "out of memory" errors. I believe you can make this operation faster by specifying only the required libraries. But for my test I installed all libraries to be on safe side.

In menu, go to Project-->Properties( Alt+F7 ).

Expand "Common Properties --> C/C++ --> General". In "Additional Include Directories" add these two entries:

    C:\Python27\include;
    C:\Boost\include\boost-1_54

Expand "Common Properties --> Linker --> General". In "Additional Library Directories" add these two entries:

    C:\Python27\libs;
    C:\Boost\lib\i386

Expand "Common Properties --> Linker --> Input".

    C:\Python27\libs\python27.lib
    C:\Boost\lib\i386\boost_python-vc90-mt-gd-1_54.lib

In order to run the application, you need to copy "C:\Boost\lib\i386\boost_python-vc90-mt-gd-1_54.dll" to your output directory (in my case it is "..\Test\Debug\").

Run the application (F5).

You should see "Hello, World" text in the console output.

Congratulations, you have successful installed boost.python, configured it with Visual C++ and embedded python interpreter inside C++ code of visual studio.

The next step is to create a Sigservice with embedded python interpreter. I will show it in next tutorial.


Front page   New List of pages Search Recent changes   Help   RSS of recent changes