-
Notifications
You must be signed in to change notification settings - Fork 263
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
r11: libc++_static.a contains symbols in libc.a (causes multiple definition error) #17
Comments
Do our docs say that somewhere? There's no reason we shouldn't support that.
It will take some rearranging at the very least (the problem here is actually |
Thanks for the reply, @DanAlbert!
That is my misunderstanding. I assumed it wasn't supported because in AOSP, static executables are created by specifying EDIT: Typo: should -> could |
Nah, static executables definitely have their uses, so we should support them. |
Sorry to keep punting this. Been working on some of the prerequisites for this but it's not going to make r13. |
What are the unified headers I've seen mentioned a few times? Will libc++ be default in r14 already? |
(unified headers bug: #120 |
libandroid_support is going to be the focus of r15, so this will be fixed as part of that effort. |
Hmm. I'm actually not sure there's anything that can be done about this. libandroid_support by design provides symbols to override libc, so we can't remove them or make them weak. I think the only option is telling the linker to allow multiple definitions when using libandroid_support (probably via libc++) for a static executable, but that's probably not something we should be doing by default. |
@DanAlbert Thanks for the reply! I agree that a hack like that probably shouldn't be enabled by default. However, if I wanted to enable it for a specific project, is it as simple as adding some LDFLAGS? EDIT: One other question: is libc++ shipped with the NDK the same as the AOSP version? If so, how are static executables, like |
Should be as simple as
Kind of. The libraries themselves are very similar, but we don't use libandroid_support in AOSP. libandroid_support is the library the provides all the things libc++ needs that were missing from Android until recently (most of the missing pieces were added in L, but a recent libc++ update actually required more so I think you don't have everything you need until you're targeting android-o). Since in AOSP we can just fix bionic to have the missing pieces, we don't need libandroid_support. In the NDK, where you want to run on older devices instead of only the absolute newest (unreleased) OS, you need libandroid_support. |
Thanks. This should be simple enough to add to my project.
That's very interesting. I'm curious as to why |
It could and in fact should, but that's actually a different issue. I've been needing to find some time to fix the AOSP build system to actually package those artifacts so we can ship them in the NDK again (you'll notice that we haven't shipped one for any recent API levels). Once we have an up to date libc.a in the NDK, you'd be able to use that with libc++_static.a and avoid libandroid_support entirely (though telling ndk-build to do that isn't intuitive, it is possible, essentially The kernel version might be an issue depending on what you're doing, but that won't be a build time issue. If something isn't available you'll get |
That all makes sense. Thanks again for the explanation. |
The
libc++_static.a
static library contains (at least) the following symbols which are defined inlibc.a
:isxdigit
vfprintf
iswalpha
towlower
towupper
__hdtoa
This makes it impossible to create a statically linked executable that uses libc++. (I realize this is not officially supported, but we don't have this problem with the bundled
libstdc++
library.)Also, the static libc++ library depends on libdl, which is available only as a shared library.
Is there any chance we could see this fixed for the next release? Thanks in advance!
Here's a very simple project for testing:
Application.mk:
Android.mk:
main.cpp:
To compile:
The text was updated successfully, but these errors were encountered: