Skip to content

gio, glib, gobject: complete lib*_dep variables.

Jehan requested to merge Jehan/glib:wip/jehan/android-master-v2 into master

This fixes building glib for Android where builds were failing with various 'undefined reference' errors.

This is an alternative fix to !87 (closed), and most likely a better one.

To give a little more details, without my commit, here is the kind of errors I was getting:

[6/663] Linking target glib/tests/asyncqueue.
FAILED: glib/tests/asyncqueue 
aarch64-linux-android-gcc  -o glib/tests/asyncqueue 'glib/tests/glib@tests@@asyncqueue@exe/asyncqueue.c.o' -Wl,--no-undefined -Wl,--as-needed -Wl,--start-group glib/libglib-2.0.so -pthread -lm -lintl -Wl,--end-group '-Wl,-rpath,$ORIGIN/..' -Wl,-rpath-link,/opt/user-cache/jehan/dev/crossbuild/android-arm64/glib/glib  
/home/jehan/.cache/crossroad/android/toolchain/android-22-arm64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: warning: libiconv.so, needed by glib/libglib-2.0.so, not found (try using -rpath or -rpath-link)
glib/libglib-2.0.so: undefined reference to `libiconv'
glib/libglib-2.0.so: undefined reference to `libiconv_open'
glib/libglib-2.0.so: undefined reference to `libiconv_close'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

As we can see, the problem was that glib/tests/asyncqueue was linked with libglib which itself had some references to libiconv, but libiconv itelf was not on the command line. This actually makes sense, since in glib/meson.build, libglib is indeed linked with libiconv but libglib_dep does not declare it as a dependency. This is probably the source error.

My previous MR !87 (closed) was fixing the consequences, whereas this new MR instead fixes directly libglib_dep by declaring correctly libiconv in the dependency list. It also does the same for libgio_dep and libgobject_dep.

I have no idea why you don't get the errors in your CI runner, but with this new fix, we clearly see the source of the issue and the fact that these link flags are definitely the right way (even though in some cases, apparently it works also without).

For the record also, I configure with -Diconv=gnu for Android.

Merge request reports