我正试图在Boost.Python中找到,我无法包装任何类。我可以创建保持功能的.pyd
,但是当我用类创建它时,我得到了这个:
TypeError: cannot create 'Boost.Python.class' instances.
所以我有3个文件:myPoint.h
,myPoint.cpp
,classPoint.cpp
。我做错了什么?
myPoint.h
struct myPoint {
int x, y;
myPoint(int _x, int _y);
};
myPoint.cpp
#include "myPoint.h"
myPoint::myPoint(int _x, int _y): x(_x), y(_y) {}
classPoint.cpp
#define BOOST_PYTHON_STATIC_LIB
#include <boost\python.hpp>
#include "myPoint.h"
BOOST_PYTHON_MODULE(classPoint) {
using namespace boost::python;
class_<myPoint>("myPoint", init<int, int>());
}