Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Return a pointer to object defined by another pybind11 library #2789

Closed
eronconi opened this issue Jan 12, 2021 · 1 comment
Closed

Comments

@eronconi
Copy link

Hi all!

I am trying to accomplish a task similar to the one described by issue #616.

I have developed two independent C++ libraries: libX and libY. Each library has its own separate python3 binding written using pybind11.

ObjX is defined in libX while ObjY is defined in libY. libX includes and dynamically links libY.

ObjX has a method getInternalHandler with the following signature:

ObjY * ObjX::getInternalHandler()

ObjY has no copy constructor and cannot be copied. Is it possible to correctly bind ObjX::getInternalHandler() ?

Thank you all

@eronconi
Copy link
Author

Solved by using std::shared_ptr<ObjY> instead of raw pointer.

At first it didn't work because libX and libY used a different version of pybind11 (both projects had pybind11 as git submodule, checked out at different commits).

After matching pybind11 versions and switching to smart pointers, it worked out of the box. Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant