libpointmatcher
libpointmatcher copied to clipboard
Fix pybind __eq__ methods
Description
Summary:
Fixed an unknown symbol error when importing libpointmatcher's Python bindings on arm64-based MacOS. Also, fixed failing tests on new boost version.
Changes and type of changes (quick overview):
- When importing
pypointmatcherin Python on arm64-based MacOS, I was getting this error:
"ImportError: dlopen(/Volumes/CaseSensitive/libpointmatcher/python/pypointmatcher/pypointmatcher_native.cpython-312-darwin.so, 0x0002): symbol not found in flat namespace '__ZNK14PointMatcherIOIfE10PLYElementeqERKS1_'"
Demangling the symbol error, it complains about this function:
bool PointMatcherIO<float>::PLYElement::operator==(const PointMatcherIO<float>::PLYElement&) const
- Following this discussion, I replaced the direct definitions of the
__eq__method withpybind11::self == pybind11::selfandpybind11::self != pybind11::selfand overwriting the C++operator==andoperator!=with friend functions. - I think that the issue did not occur on Ubuntu distros due to different build tools, but I'm not certain. In any case, it solves the problem on MacOS.
Checklist:
Code related
- [x] I have made corresponding changes to the documentation (i.e.: function, class, script header, README.md)
- [x] I have commented hard-to-understand code
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] All tests pass locally with my changes (Check contributing_instructions.md for local testing procedure using libpointmatcher-build-system)
PR creation related
- [x] My pull request
base refbranch is set to thedevelopbranch (the build-system won't be triggered otherwise) - [x] My pull request branch is up-to-date with the
developbranch (the build-system will reject it otherwise)
PR description related
- [x] I have included a quick summary of the changes
- [x] I have indicated the related issue's id with
# <issue-id>if changes are of typefix - [x] I have included a high-level list of changes and their corresponding types (See commit_msg_reference.md for details)