简体   繁体   中英

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?

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.

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.

另一种方法是使用swig(http://www.swig.org/)生成一个包装C ++代码的python模块。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM