我想在一个项目中集成实用工具pybind11。我的工作环境是窗户。
要安装pybind11,有以下页面:第一集
我在windows下试了几次,几天(3),用Eclipse,然后用Python和明代。然后使用
,在所有这些之后,我尝试了Linux,在1小时内,我来到了这个示例:
#include <pybind11 / pybind11.h>
int add (int i, int j) {
return i + j;
}
PYBIND11_MODULE (example, m) {
m.doc () = "pybind11 example plugin"; // optional module docstring
m.def ("add", & add, "A function which adds two numbers");
}c++ -O3 -Wall -shared -std =c ++ 11 -fPIC
python3 -m pybind11 --includesexample.cpp -o示例python3-config --extension-suffix
除了Python之外的测试。
之后,我决定用cygwin让它成功。
以下是我的处境:
easy_install-3.6 pip
python3 -m pip install pytest
python3 -m pip install pybind11
python3 -m pip install python-config然后在pybind11 11-母机下
mkdir build
cd build
cmake ..
make check -j 4我有两条警告和一条便条:
警告:"pybind11 ::buffer (pybind11 ::handle,bool)“被否决:使用reinterpret_borrow ()或reinterpret_steal () -Wdeprecated声明
当链接时,这里有一个错误,但有很多。
/tmp/ccqNl6ln.ltrans0.ltrans.o::(.text+0x12f16):未定义的对"pybind11 ::index_error ::index_error () .lto_priv.4841“的引用
对于这个项目,pybind11实际上是一个+。但是我不能在Windows上使用它。
曾经有人用cygwin?编译过pybind11
先谢谢你
发布于 2018-11-02 18:11:53
在安装了pip之后,三个模块
python3 -m pip install pytest
python3 -m pip install pybind11
python3 -m pip install python-config下面的示例工作
#include <pybind11/pybind11.h>
int add (int i, int j) {
return i + j;
}
PYBIND11_MODULE (example, m) {
m.doc () = "pybind11 example plugin"; // optional module docstring
m.def ("add", & add, "A function which adds two numbers");
}如汇编为:
c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix) -lpython3.6mhttps://stackoverflow.com/questions/53115907
复制相似问题