Jump to content
  • entries
  • comments
  • views

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

Sign in to follow this  


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  


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
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!