pybind11 -Importerror:未定义的符号:_py_zerostruct
我正在关注 pybind11
文档,并尝试为简单函数创建python绑定为简单函数创建绑定,但是在用以下命令将我的C ++代码编译后:
g++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cc -o example$(python3-config --extension-suffix)
当我尝试在python中导入库时,请使用:
import example
i获取 ImporterRor
说未定义的符号:_PY_ZEROSTRUCT
我正在使用:
- ubuntu :
ubuntu 20.04.4 lts
- python :
Python 3.8.10
- pip :
pip 20.0.2
我试图解决的问题
我研究了许多文章与同一错误有关,但实际上无法了解我将如何解决我的问题:
任何类型的帮助都将不胜感激。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,在尝试了许多方法之后,我最终决定将
pybind11
作为我的项目中的子模型,并使用python3.9
,这次似乎可以使用。任何遇到相同问题的人都可以尝试我的方法,它可能起作用,不要期望这个残酷的社区的帮助。
Well after trying a lot of methods I finally decided to add
pybind11
as a submodule in my project and usePython3.9
and it seemed to work this time.Anyone struggling with the same problem can try my method, it may work and don't expect help from this cruel community.