如何使用python的c ++库?

How to use a c++ library with python?

本问题已经有最佳答案,请猛点这里访问。

我有一个用C++编写的复杂项目的.so文件。有没有一种方法可以将这个库与python一起使用?我不应该对现有C++文件进行任何代码更改。在每个文件中用Po.ST.Py编写C++包装器是唯一的方法吗?这样做会影响代码的运行时吗?


Swig是一个选项:猛击教程

尽管调试核心转储会让人非常沮丧:)


是的,可以用Python调用C++代码,其中EDCOX1为0。

The Boost Python Library is a framework for interfacing Python and
C++. It allows you to quickly and seamlessly expose C++ classes
functions and objects to Python, and vice-versa, using no special
tools -- just your C++ compiler. It is designed to wrap C++ interfaces
non-intrusively, so that you should not have to change the C++ code at
all in order to wrap it, making Boost.Python ideal for exposing
3rd-party libraries to Python. The library's use of advanced
metaprogramming techniques simplifies its syntax for users, so that
wrapping code takes on the look of a kind of declarative interface
definition language (IDL).