-
Notifications
You must be signed in to change notification settings - Fork 68
[native_toolchain_c] Shared library build doesn't include libc++_shared.so despite requiring it (Android) #2099
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
Comments
A solution also needs to take into account that multiple packages might need |
If we wanted to dedupe multiple A way to make this work, with multiple packages collaborating, would be to define a The alternative, deduplicating duplicately defined assets seems like a bad design choice. However, this kind of means that we'll start needing Dart wrapper packages for all kinds of shared libraries that people might be needing. Maybe that's the right thing to do, it ensures a single-version policy. But it also feels somewhat painful to have to collaborate across possibly unrelated packages. I'm open to alternative suggestions. Some related issues:
|
@dcharkes I guess conceptually, it could go in a few directions:
I definitely see your point about duplicate assets, but I don't think I understand enough about the destination structure, because if I get the point, then that means if someone uses two different dart packages that e.g. provide different layers of database abstraction, but both decided to implement their own native That's probably an extreme edge case, but the implications extend to shared libraries and any native compiled code, and I'm not sure that having packages for shared libs would avoid the issue. Alternatively (this may be a stupid suggestion) would it be possible to do some kind of final build step, where all assets from the root package and dependencies are collated and where there's name match (e.g. I haven't even started with tree-shaking yet, but I will have to get around to it once I've built up a stable API. Edit: |
They cannot be in separate directories. Moving dynamic libraries to be in a different location requires rewriting dynamic libraries that open them to change the opening path. This is supported on MacOS/iOS but not on the other OSes. This means all dynamic libraries are in one directory and one namespace. This is typically how C compiler work. Hence, therefore everyone would need to agree on what The only way to have multiple of the same dynamic library is if you modify the compilation of sqlite to output a dylib with a different name
I thought about this option as well, but I'm thinking that this is a bad design, because that's not how other package managers work. It would complicate the logic for the SDKs as well. Unduplicating code between two packages is done by moving it to a shared dependency. Unduplicating assets between two packages is done by moving the assets to a shared dependency.
For tree-shaking you need to pass |
That's a good point, and has implications for the lib I'm making.
I agree, that would add unnecessary complexity, and clearly it would be better to have one source for a particular native library anyway.
Yeah, this is probably the way to go. I think it would be nice to have some kind of (soft)enforced standard. For this design, what could help a lot is:
Great, I'll definitely be testing this out, I don't plan to require flutter for the native asset anyway, apart from the separate test package which will use integration tests to make sure it's working on different platforms. As an aside, (maybe this is common/known knowledge, I haven't searched the issues), getting this working in Android mean I could immediately also deploy to a Quest 2, and it worked without issues which is awesome for research and also game contexts. For the rest of this discussion, I think I will bow out because it seems like a major design decision which I don't have particularly strong opinions on, and probably should be decided by others who know more about the roadmap and internals. |
When targeting android with
CBuilder.library
if the sources use the stdlib then officially the android documentation state that you are required to manually bundle thelibc++_shared.so
but this isn't bundled, and as far as I can tell there's no easy way to do this.The same build works for all other targets I've tested so far (Windows, iOS, OSX).
the full implementation I've done is available here: https://github.com/zeyus/liblsl.dart/blob/5335a97670a28a1b2464210f7c25a3878afb8ecd/packages/liblsl/hook/build.dart
I've come up with a workaround, but it feels like a bit of a perversion of the "public" API.
What might be nice is exposing a target-specific stdlib path, or otherwise perhaps just a flag to include the
libc++_shared.so
asset.Of course, maybe I missed something obvious where adding some compiler flag or define would bundle the .so, but I tried a few things and it didn't work.
The text was updated successfully, but these errors were encountered: