glib fails to compile for Android API level >=28
With target_distro_version = DistroVersion.ANDROID_PIE
, glib fails to compile with error: undefined reference to 'libiconv_open'
and similar messages. The reason is explained in Android's fork of glib:
Note that if you have libiconv installed in your default include search path (for instance, in /usr/local/), but don't enable it, you will get an error while compiling GLib because the iconv.h that libiconv installs hides the system iconv.
That is, glib's autodetection choose to use Android's iconv (which is available in API level >= 28), but then the compilation includes libiconv's header, which doesn't work with Android's implementation.
There're a couple ways to fix this:
- Set option
iconv
toexternal
which makes glib uses libiconv. However, it's possible that other libraries will have the same problem and may not have a similar flag (I didn't check). It also makes the bundle unnecessarily larger if one targets Android 9 and up. - Do not include
libiconv
if the target API is at least 28. However, this requires every recipe to do the same. If one recipe ever requires libiconv, glib (and potentially other libraries) will fail to build. One probably wants to add a helper to help determine that somewhere.
Thus, I open this issue to seek for the best way to solve this.
Why do I want to use API level 28? I want to make use of the NDK version of MediaCodec and SurfaceTexture. I'll file an issue on the gst-plugins-bad explain the reasoning in more detail (spoiler: libhybris).