• entries
    17
  • comments
    28
  • views
    26994

Interfacing C++ and Python (Part 1 & 2 Sample source code)

Sign in to follow this  
Nit

616 views

By request, I'm attaching some sample source code that demonstrates the topics covered in my last two postings. This is a basic solution for calling into Python from C++.

I've also included in the attached zipfile, notes on how to configure a Visual Studio 2008 solution to use Python26. I expect it is straightforward to translate these steps to work with a different compiler, or another version of Python. For completeness, these notes are included here:

Notes for creating the Project in Visual Studio 2008
Assumes Python26 is installed at C:\Python26, so be sure to update the paths listed below if you are using a different version of python.
  • Create a New Project --> Win32 Console Application, No precompiled Headers, Empty Project
  • Add main.cpp, pythonCallbacks.h, pythonCallbacks.cpp files to solution
  • Right click on PythonCppExample --> Properties
    • C/C++ --> General --> Additional Include Directories = C:\Python26\include
    • Linker --> General --> Additional Library Directories = C:\Python26\libs
    • (NOTE: Notice it is the libs directory, not the Lib directory)
    • Linker --> Input --> Additional Dependencies = python26.lib
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now