Boost.Python无法创建“Boost.Python.class”实例

时间:2014-02-19 19:01:00

标签: python c++ boost

我正试图在Boost.Python中找到,我无法包装任何类。我可以创建保持功能的.pyd,但是当我用类创建它时,我得到了这个:

TypeError: cannot create 'Boost.Python.class' instances.

所以我有3个文件:myPoint.hmyPoint.cppclassPoint.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>());
}

0 个答案:

没有答案