Building static binaries with universal headers (NDK r15)

335 views
Skip to first unread message

kwl...@gmail.com

unread,
Jun 29, 2017, 11:47:17 AM6/29/17
to android-ndk
When trying to build static binaries using NDK r15 (unified headers), I'm encountering "undefined reference to stderr/stdin/stdout".

I can work around this by using the deprecated headers, but if I understand correctly these will be removed eventually.

Has anyone encountered this issue?
Does anyone know a fix for this?

Dan Albert

unread,
Jun 29, 2017, 12:04:36 PM6/29/17
to android-ndk
Static binaries aren't supported very well. We don't have static libraries for anything newer than android-21. If you target 21, it should work.

Fixing this is on the todo list, btw. Probably will be part of r17.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/7a30a6a9-951d-49e5-a33a-ee601f4b9028%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

kwl...@gmail.com

unread,
Jun 29, 2017, 6:30:40 PM6/29/17
to android-ndk
Ok great, thanks.


On Thursday, June 29, 2017 at 11:04:36 AM UTC-5, Dan Albert wrote:
Static binaries aren't supported very well. We don't have static libraries for anything newer than android-21. If you target 21, it should work.

Fixing this is on the todo list, btw. Probably will be part of r17.
On Thu, Jun 29, 2017 at 8:45 AM, <kwl...@gmail.com> wrote:
When trying to build static binaries using NDK r15 (unified headers), I'm encountering "undefined reference to stderr/stdin/stdout".

I can work around this by using the deprecated headers, but if I understand correctly these will be removed eventually.

Has anyone encountered this issue?
Does anyone know a fix for this?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.

Alex Cohn

unread,
Jul 2, 2017, 4:24:27 AM7/2/17
to android-ndk
That's strange; we use static libraries a lot in our build script. Or maybe you create a static lib which is used in a different project as prebuilt? In this case, make sure that the target API level is the same.

BR,
Alex Cohn

Dan Albert

unread,
Jul 10, 2017, 10:55:06 PM7/10/17
to android-ndk
We don't have static libraries for anything newer than android-21.

I was too vague here. We don't have libc.a or libm.a for anything newer than android-21.

Building your own static libraries will work fine, it's static executables that don't work well. libc.a doesn't get used in JNI code (you're in for some really fun bugs if you ever try!), which is why getting that fixed is a ways down on the priority list. There isn't really much reason to do it aside from making an executable that builds against 21 but runs on 14 (though networking isn't really going to work in a static executable on anything but the release it targets because the protocol libc uses to talk to netd is baked into that static library and has changed many times).

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+unsubscribe@googlegroups.com.

To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
Reply all
Reply to author
Forward
0 new messages