Windows/Cygwin - 不能使用 pybind11 - 犯错误

Windows/Cygwin - Can't use pybind11 - make error

本文关键字:pybind11 犯错误 不能 Cygwin Windows      更新时间:2023-10-16

我想在一个项目中集成实用工具pybind11。我的工作环境是窗户。

要安装pybind11,有以下页面:Pybind First设置

我在窗户下试了好几次,好几天(3(,使用Eclipse,然后使用Python和Mingw。然后使用Visual Studio

在所有这些之后,我尝试了Linux,在一个小时内我得到了这个例子:

#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-墙共享-std=c++11-fPICpython3 -m pybind11 --includes示例.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主下

mkdir build
cd build
cmake ..
make check -j 4

我有两条警告和一条注释:

警告:"pybind11::buffer::buffer(pybind11:::handle,bool

链接时,这里有一个错误,但有很多错误。

/tmp/ccqNl6ln.ltrans0.ltrans.o::(.text+0x12f16(:对"pybind11::index_error::index_eerror(([clone.lto_priv.4841][clone.lto_priv.4883]"的未定义引用

pybind11对于项目来说确实是一个加号。但我不能在Windows上使用它。

有人用cygwin编译过pybind11吗

提前非常感谢

用pip安装3个模块后

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.6m