gio/tests/unix-fd test requires additional libraries on Solaris and possibly other platforms
Submitted by Tim Mooney
Link to original bug (#614381)
Description
The link fails for gio/tests/unix-fd on Solaris, where "socketpair" is not in libc.
Making all in tests
gmake[4]: Entering directory `/local/src/RPM/BUILD/glib-2.24.0/gio/tests'
/bin/bash ../../libtool --tag=CC --mode=link cc -Xa -xO3 -xstrconst -mt -KPIC -xtarget=native -m64 -xarch=native -I/local/gnu/include -I/local/gnu/include -L/local/gnu/lib/64 -L/local/gnu/lib/64 -o unix-fd unix-fd.o ../../glib/libglib-2.0.la ../../gobject/libgobject-2.0.la ../../gio/libgio-2.0.la -lintl
libtool: link: cc -Xa -xO3 -xstrconst -mt -KPIC -xtarget=native -m64 -xarch=native -I/local/gnu/include -I/local/gnu/include -o .libs/unix-fd unix-fd.o -L/local/gnu/lib/64 ../../glib/.libs/libglib-2.0.so ../../gobject/.libs/libgobject-2.0.so ../../gio/.libs/libgio-2.0.so /local/src/RPM/BUILD/glib-2.24.0/gobject/.libs/libgobject-2.0.so /local/src/RPM/BUILD/glib-2.24.0/gthread/.libs/libgthread-2.0.so -lpthread -lthread -lrt /local/src/RPM/BUILD/glib-2.24.0/gmodule/.libs/libgmodule-2.0.so /local/src/RPM/BUILD/glib-2.24.0/glib/.libs/libglib-2.0.so -lresolv -lz /local/gnu/lib/64/libintl.so -lc -mt -R/local/gnu/lib/64
ld: warning: file /local/src/RPM/BUILD/glib-2.24.0/gobject/.libs/libgobject-2.0.so: linked to ../../gobject/.libs/libgobject-2.0.so: attempted multiple inclusion of file
ld: warning: file /local/src/RPM/BUILD/glib-2.24.0/glib/.libs/libglib-2.0.so: linked to ../../glib/.libs/libglib-2.0.so: attempted multiple inclusion of file
Undefined first referenced
symbol in file
socketpair unix-fd.o (symbol belongs to implicit dependency /lib/64/libsocket.so.1)
Now that I've looked a little closer, I'm a little confused about how the link for libgio is even working. I think it's because libresolv is linked against libsocket and libnsl and libgio is linking against libresolv. I don't understand why that isn't sufficient for unix-fd, though. Maybe because one is a shared library and the other is an executable, but that's just a wild guess.
You may wish to investigate incorporating the same checks that gtk+ uses, to detect whether additional networking libraries (-lsocket -lnsl) are required, and then make those libraries an explicit dependency for libgio? I'm not certain if that's the best approach or not, but I have this feeling that there's a potential problem lurking here for any platform where additional networking libraries are required.
Version: 2.24.x