-
Notifications
You must be signed in to change notification settings - Fork 110
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
Linking against C++ STL and using it at runtime #19
Comments
Looks good. I think you can turn it into a one liner: let search_path = if c++ { android_search_path } else { search_path } |
@dvc94ch That would be a nice solution, but Furthermore, this specific library needs to be excluded from the Would this work for you? As for the other points: should I bring the default lib issue up over at |
Looks good, if you PR that, I'll merge it. Don't know how common it is to only use |
It is not so much about the barebones Thanks for accepting the patches thus far! |
Native C++ code (in external dependencies) that utilize the STL have a hard time linking and running on-device. Dependencies usually set
cpp_link_stdlib
(if using thecc
crate) to something sensible or leave it at the defaultstdc++
which only works for GNU but not Clang, requiringc++
instead. Only a single dependency needs to set it toc++
orc++_shared
for the right library to be linked in and succeed the build. Leavingstdc++
in there is fine, this library is available on-device, providing onlynew
anddelete
.I assume the right course of action is to add an
android
case withc++
to the defaults in cc? (Or in the exceptional case, do that for all of clang? The documentation mentions this case yet does not account for it.)As mentioned here
libc++_shared
is not available on Android devices - it needs to be bundled with the APK. Builds link againstc++_static
by default and have no runtime dependencies, but aforementioned native projects would force linking againstc++
.A simple solution adds the path to
libc++_shared.so
fromandroid_search_paths
toartifacts
in readelf.rs, if it is found in the needed libs (like this - forgive the awful code and duplication from a Rust novice). A more sophisticated implementation would provide the option to choose between none, static or runtime STL (including the file for the latter) and clean up linker flags to accommodate this choice.Any suggestions going forward? I'm willing to take this onwards but am not sure how to proceed.
The text was updated successfully, but these errors were encountered: