We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b00a8b1 commit 9e1987aCopy full SHA for 9e1987a
2 files changed
section4/demo.py
@@ -0,0 +1,6 @@
1
+#!/usr/bin/python3
2
+
3
+import pydemo
4
5
+x = pydemo.add(1,2)
6
+print(x)
section4/pybind.cpp
@@ -0,0 +1,35 @@
+// Copyright (c) 2020 by Chrono
+//
+// apt install python3-pip
+// pip3 install pybind11
+// apt install python3-dev
7
+// mkdir build && cd build
8
+// cmake .. -DPYBIND11_TEST=OFF
9
10
+// g++ -shared -std=c++11 -fPIC `python3 -m pybind11 --includes` pybind.cpp -o pydemo`python3-config --extension-suffix`
11
12
+#include <pybind11/pybind11.h>
13
14
+int add(int a, int b)
15
+{
16
+ return a + b;
17
+}
18
19
+PYBIND11_MODULE(pydemo, m)
20
21
+ m.doc() = "pybind11 doc";
22
+ m.def("add", &add, "add func");
23
24
25
+#if 0
26
27
+#include <iostream>
28
29
+int main()
30
31
+ using namespace std;
32
33
+ cout << "pybind demo" << endl;
34
35
+#endif
0 commit comments