-
Notifications
You must be signed in to change notification settings - Fork 781
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
dynamic_cast won't work across dylib boundaries on macOS #218
Comments
So note for everyone: After some careful thought, I think the best way of handling RTTI-based dynamic dispatch with header-only libraries is to NOT make their objects cross shared library boundaries. For example, an |
I don't understand this :-) |
The idea is that the same type may have different |
So I have a solution here: quoting Apple documentation: Command Line Options for VisibilityThe visibility command line options are useful for setting the visibility defaults. This can be especially helpful when dealing with source code which is third party, or otherwise for some reason not practical to decorate with attributes or pragmas. If you do not specify a command line visibility option then symbols will be marked visible (unless overridden by one of the other three techniques). You can make this choice of default visibility explicit by placing the following on your command line:
Specifying There are two other visibility-related command options one may find useful:
This will solve the typeid issue on macOS (matching the Linux behavior). I think it is also worthwhile to add this to the docs as there may be future projects dynamically linking to GTSAM on macOS. |
@ProfFan that's a lot of good info, but what is concisely the proposed solution ? :-) |
|
If you can verify it solves our issue on Mac, then, yes, let's adopt and document this solution. Great find! |
Let's close after PR is merged? |
Copy :) |
Currently the python wrapper will fail for some dynamic_casts as the type_info for the same type changes between dylibs. Now it is mitigated by compiling GTSAM statically, but still need to resolve sooner or later.
See #217
The text was updated successfully, but these errors were encountered: