G-71
G-71

Reputation: 3682

The best way to call C++ function from shared object in python

What's the best way to call C++ function from shared object in python. Can I can solve this problem without additional python extension?

Upvotes: 1

Views: 488

Answers (3)

Chris Card
Chris Card

Reputation: 3266

Another way is to use swig (http://www.swig.org/) to generate a python module wrapping the C++ code.

Upvotes: 1

01100110
01100110

Reputation: 2344

If you have the C++ source code, I would say boost python is the best way because it's very easy to get this up and running and it's flexible. If you don't have C++ source then checkout ctypes.

Upvotes: 2

Tom Whittock
Tom Whittock

Reputation: 4220

Perhaps you could investigate ctypes, although you will need to know things like the mangled name of the function and the correct calling convention.

If that doesn't work you'll need to create a C wrapper around the C++ code.

Upvotes: 3

Related Questions