pybind11 教程
最编程
2024-07-15 08:54:52
...
#include <pybind11/pybind11.h>
int add( int i, int j ){
return i+j;
}
PYBIND11_MODULE(example, m ){
m.doc() = "pybind11 example";
m.def("add", &add, "add two number" );
}
//在python中使用 模块名.函数名 来访问
//例如本例子为 example.add(1,2)
参考文献https://pybind11.readthedocs.io/en/stable/basics.html
在linux上用以下命令构建
c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix)
在windows上使用教程参考
推荐阅读
-
[C 语言教程] [嵌入式程序设计] (I) 简介和先决条件 (II) 嵌入式程序设计基础 (III) 硬件基础 (IV) 硬件寄存器操作
-
OpeneBayes 教程 | LLaVA-OneVision,一个强大的开源多模态宏模型,可击败 GPT-4V,现已上线!
-
设计并实施基于 SpringBoot 的 DIY 计算机安装教程网站。
-
系统架构设计器教程 第 19 章 19.4 Kappa 架构说明
-
Python 教程:Python 中的集合及其对集合的所有操作
-
node.js 下载和安装以及环境配置超级详细教程 [Windows 版本]。
-
部署项目最新教程
-
多线程保姆级基础教程
-
人工智能控制工业机器人入门教程
-
图像去雾 - 图像去残留(matlab/python 代码 + 教程)