On MSVC 9, test-select does not link, because for the functions DispatchMessageA TranslateMessage PeekMessageA MsgWaitForMultipleObjects linking with -luser32 is necessary. On mingw, this linker option is apparently included by default.
This fixes it. 2011-09-22 Bruno Haible <br...@clisp.org> select: Avoid link errors on MSVC. * m4/select.m4 (gl_FUNC_SELECT): Determine LIB_SELECT. * modules/select (Link): Replace $(LIBSOCKET) with $(LIB_SELECT). * modules/pselect (Link): Likewise. * NEWS: Mention the change. * modules/select-tests (Makefile.am): Link test-select, test-select-fd, test-select-stdin against $(LIB_SELECT). * modules/pselect-tests (Makefile.am): Link test-pselect against $(LIB_SELECT). --- NEWS.orig Thu Sep 22 23:38:28 2011 +++ NEWS Thu Sep 22 22:56:05 2011 @@ -12,6 +12,9 @@ Date Modules Changes +2011-09-22 select The link requirements of this module are changed + from $(LIBSOCKET) to $(LIB_SELECT). + 2011-09-12 fchdir This module no longer overrides the functions opendir() and closedir(), unless the modules 'opendir' and 'closedir' are in use, respectively. --- m4/select.m4.orig Thu Sep 22 23:38:28 2011 +++ m4/select.m4 Thu Sep 22 22:59:01 2011 @@ -1,4 +1,4 @@ -# select.m4 serial 5 +# select.m4 serial 6 dnl Copyright (C) 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -47,4 +47,29 @@ *) REPLACE_SELECT=1 ;; esac fi + + dnl Determine the needed libraries. + LIB_SELECT="$LIBSOCKET" + if test $REPLACE_SELECT = 1; then + case "$host_os" in + mingw*) + dnl On the MSVC platform, the function MsgWaitForMultipleObjects + dnl (used in lib/select.c) requires linking with -luser32. On mingw, + dnl it is implicit. + AC_LINK_IFELSE( + [AC_LANG_SOURCE([[ +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +int +main () +{ + MsgWaitForMultipleObjects (0, NULL, 0, 0, 0); + return 0; +}]])], + [], + [LIB_SELECT="$LIB_SELECT -luser32"]) + ;; + esac + fi + AC_SUBST([LIB_SELECT]) ]) --- modules/pselect.orig Thu Sep 22 23:38:29 2011 +++ modules/pselect Thu Sep 22 22:37:42 2011 @@ -23,7 +23,7 @@ <sys/select.h> Link: -$(LIBSOCKET) $(LIB_PTHREAD_SIGMASK) +$(LIB_SELECT) $(LIB_PTHREAD_SIGMASK) License: LGPLv2+ --- modules/pselect-tests.orig Thu Sep 22 23:38:29 2011 +++ modules/pselect-tests Thu Sep 22 22:39:54 2011 @@ -30,4 +30,4 @@ Makefile.am: TESTS += test-pselect check_PROGRAMS += test-pselect -test_pselect_LDADD = $(LDADD) @LIBSOCKET@ @LIB_PTHREAD_SIGMASK@ $(INET_PTON_LIB) +test_pselect_LDADD = $(LDADD) @LIB_SELECT@ @LIBSOCKET@ @LIB_PTHREAD_SIGMASK@ $(INET_PTON_LIB) --- modules/select.orig Thu Sep 22 23:38:29 2011 +++ modules/select Thu Sep 22 23:28:01 2011 @@ -23,7 +23,7 @@ <sys/select.h> Link: -$(LIBSOCKET) +$(LIB_SELECT) License: LGPLv2+ --- modules/select-tests.orig Thu Sep 22 23:38:29 2011 +++ modules/select-tests Thu Sep 22 22:39:51 2011 @@ -36,6 +36,6 @@ TESTS += test-select test-select-in.sh test-select-out.sh # test-select-stdin has to be run by hand. check_PROGRAMS += test-select test-select-fd test-select-stdin -test_select_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB) -test_select_fd_LDADD = $(LDADD) @LIBSOCKET@ -test_select_stdin_LDADD = $(LDADD) @LIBSOCKET@ +test_select_LDADD = $(LDADD) @LIB_SELECT@ @LIBSOCKET@ $(INET_PTON_LIB) +test_select_fd_LDADD = $(LDADD) @LIB_SELECT@ +test_select_stdin_LDADD = $(LDADD) @LIB_SELECT@ -- In memoriam Martha Corey <http://en.wikipedia.org/wiki/Martha_Corey>