SIGVerse with Python


If you questions after reading this page: Please feel free to email at jain@nii.ac.jp


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

This tutorial is independent of SIGVerse simulator and anyone who wants to embed a python interpreter inside C++ source code using Visual Studio can use this.

Please note that:

Okay, here are the steps.

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

Note: X in above command, is the number of threads your PC can handle. Please go to My Computer(right click)-->Device Manager --> Processors to see the list of processors you have. Usually, the list of processors are equal to no. of threads that could be run concurrently. So, its 4 processors, please use -j4 option.

This will compile both static and shared libraries and install them to the specified path.

Please note that, if you use the option to parallelize the compilation available for gcc (-jX where X is the number of thread handled by the machine processor) then it will be faster, otherwise this operation takes a lot of time (more or less around one hour), a lot of memory and a lot of disk space. So, if you are not using the -jX option, then please make sure to close all unnecessary programs to avoid "out of memory" errors. I believe you can make this operation much faster by specifying only the required libraries. But for my test I installed all libraries to be on safer 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.

Counter: 6950, today: 1, yesterday: 0

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