I'm following the pybind11
documentation and trying to create Python bindings for a simple function Creating bindings for a simple function, but after compiling my C++ code with the following command:
g++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cc -o example$(python3-config --extension-suffix)
when I try to import the library in python using:
import example
I get an ImportError
saying undefined symbol: _Py_ZeroStruct
I'm using:
- Ubuntu :
Ubuntu 20.04.4 LTS
- Python :
Python 3.8.10
- Pip :
Pip 20.0.2
What I tried to solve the issue
I looked into many articles related to the same error but couldn't really get an understanding of how I'm going to resolve my issue:
- Python3.5 incompatibility: undefined symbol
- ImportError: undefined symbol: _Py_ZeroStruct
- undefined symbol using pybind11 cmd
- Undefined Symbol error when linking pybind11 with a dynamic library that calls an external function
Any kind of help will be greatly appreciated.