pybind11使用学习
https://www.jianshu.com/p/9619f8f02891
https://www.cnblogs.com/wildkid1024/p/17488842.html
添加引用,添加库
编写代码,主要动态链接库的名称AxTopo4bim应该和PYBIND11_MODULE(AxTopo4bim, m)中的一致。
#include "stdafx.h"
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
namespace py = pybind11;
PYBIND11_MODULE(AxTopo4bim, m)
{
m.doc() = "pybind11 example module";
// Add bindings here
m.def("foo", []() {
return "Hello, World!";
});
m.def("foo2", []() {
return "This is foo2!\n";
});
m.def("add", [](int a, int b) {
return a + b;
});
m.def("sub", [](int a, int b) {
return a - b;
});
m.def("mul", [](int a, int b) {
return a * b;
});
m.def("div", [](int a, int b) {
return static_cast<float>(a) / b;
});
}
作者:太一吾鱼水
文章未经说明均属原创,学习笔记可能有大段的引用,一般会注明参考文献。
欢迎大家留言交流,转载请注明出处。
浙公网安备 33010602011771号