Replies: 1 comment 2 replies
-
@shadowqwq Did you manage to find the reason or a solution ? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to link a pybind11 module with a
.so
shared library, and the library calls functions not implemented in the.so
file. It works fine in a normal c++ executable file, but raisesUndefined Symbol
error when imported in python.Here is a simple demo to reproduce my problem.
The function
Student::print()
is complied to a dynamic library and it calls a functionStudent::setId()
that is not included in the.so
file. (If usenm
command, it will showU _ZN7Student5setIdEi
.)It works fine in
main.cpp
to callStudent::print()
, but intest.py
, it raisesImportError: {mypath}/libstu_lib.so: undefined symbol: _ZN7Student5setIdEi
To simplify, I set the external function to be its own member function. The problem still reproduces when calling functions belonging to another classes, so I think it doesn't matter.
Is there any option in pybind11 to deal with this problem? Because it is difficult to modify the source code of the dynamic library. Thanks.
Student.h
Student.cpp
Student_lib.cpp
Student_wrapper.cpp
CMakeLists.txt
main.cpp
test.py
Beta Was this translation helpful? Give feedback.
All reactions