vs2015编译pyd后,报错:
ImportError: dynamic module does not define module export function (PyInit_example)
原因:
PYBIND11_MODULE(binddemo, m)
{
// optional module docstring
m.doc() = "pybind11 example plugin";
// expose add function, and add keyword arguments and default arguments
m.def("add", &add, "A function which adds two numbers", py::arg("i") = 1, py::arg("j") = 2);
// exporting variables
m.attr("the_answer") = 42;
py::object world = py::cast("World");
m.attr("what") = world;
}
binddemo 这个需要和pyd的名字保持一致
add就是函数的名字