Hi Paul, When compiling a testdir for the 'getloadavg' module on Solaris 2.6 - which does not have getloadavg in libc, unlike Solaris 7 -, I get this error:
cc -O -g -o test-getloadavg test-getloadavg.o ../gllib/libgnu.a ild: (undefined symbol) kstat_read -- referenced in the text segment of ../gllib/libgnu.a(getloadavg.o) ild: (undefined symbol) kstat_open -- referenced in the text segment of ../gllib/libgnu.a(getloadavg.o) ild: (undefined symbol) kstat_data_lookup -- referenced in the text segment of ../gllib/libgnu.a(getloadavg.o) ild: (undefined symbol) kstat_close -- referenced in the text segment of ../gllib/libgnu.a(getloadavg.o) ild: (undefined symbol) kstat_lookup -- referenced in the text segment of ../gllib/libgnu.a(getloadavg.o) *** Error code 5 make: Fatal error: Command failed for target `test-getloadavg' The reason is that getloadavg.m4 has set GETLOADAVG_LIBS to "-lkstat -lkvm -lelf ", but nothing uses it. (Also, only -lkstat would already be sufficient. At least in Solaris 2.6, -lkvm and -lelf are not needed. But that it of minor importance.) Here is a proposed patch. 2011-02-17 Bruno Haible <[email protected]> getloadavg: Fix link error on Solaris 2.6. * modules/getloadavg (Link): New section. * modules/getloadavg-tests (Makefile.am): Use GETLOADAVG_LIBS for linking test-getloadavg. * doc/glibc-functions/getloadavg.texi: Mention that Solaris 2.6 lacks getloadavg. --- doc/glibc-functions/getloadavg.texi.orig Fri Feb 18 01:08:51 2011 +++ doc/glibc-functions/getloadavg.texi Fri Feb 18 00:23:54 2011 @@ -8,7 +8,7 @@ @itemize @item This function is missing on some platforms: -AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Cygwin, mingw, Interix 3.5, BeOS. +AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 2.6, Cygwin, mingw, Interix 3.5, BeOS. @item This function is declared in @code{<sys/loadavg.h>}, not @code{<stdlib.h>}, on some platforms: --- modules/getloadavg.orig Fri Feb 18 01:08:51 2011 +++ modules/getloadavg Fri Feb 18 01:02:36 2011 @@ -20,6 +20,9 @@ Include: <stdlib.h> +Link: +$(GETLOADAVG_LIBS) + License: GPL --- modules/getloadavg-tests.orig Fri Feb 18 01:08:51 2011 +++ modules/getloadavg-tests Fri Feb 18 01:03:58 2011 @@ -9,3 +9,4 @@ Makefile.am: TESTS += test-getloadavg check_PROGRAMS += test-getloadavg +test_getloadavg_LDADD = $(LDADD) @GETLOADAVG_LIBS@
