Bruno Haible <[EMAIL PROTECTED]> writes: > Simon Josefsson wrote: >> My problem is getting >> AC_SEARCH_LIBS to find functions in the mingw32 libraries. It seems a >> __stdcall is required in the prototype to make it link correctly. > > The prototype with __stdcall must be contained in a public include file, > no? (<winsock2.h>, included by your <sys/socket.h> substitute.)
Right. > It seems you will have to write a test that > 1) tries to use gethostbyname() with the #include and no additional > libraries, > 2) same thing with -lwsock32, > and set some LIB* or *_LDFLAGS variable, depending on the result. > Look how AM_ICONV_LINK (in gethostbyname.m4) does it; something like > this: Yes, I agree, and I have tested something similar. The following works: AC_SEARCH_LIBS(gethostbyname, [inet nsl]) ... if test "$ac_cv_search_gethostbyname" = "no"; then save_LIBS="$LIBS" LIBS="$LIBS -lwsock32" AC_MSG_CHECKING([whether we need -lwsock32]) AC_LINK_IFELSE([ AC_LANG_PROGRAM([[ #include <ws2tcpip.h> ]], [gethostbyname ("foo");])], need_wsock32=yes, need_wsock32=no) AC_MSG_RESULT($need_wsock32) LIBS="$save_LIBS" if test "$need_wsock32" = "yes"; then LIBS="$LIBS -lwsock32" fi fi However, it seems rather ugly. I was hoping to be able to connect to the AC_SEARCH_LIB logic somehow, so that it would do this automatically. I want to be able to add the #include <ws2tcpip.h> to the AC_SEARCH_LIB generated header. But since the above seem to work, I think I'll move on unless someone can come up with something cleaner. Thanks! > AC_CACHE_CHECK(for gethostbyname, gl_cv_func_gethostbyname, [ > gl_cv_func_gethostbyname=no > gl_cv_lib_gethostbyname=no > AC_TRY_LINK([ > #if HAVE_SYS_SOCKET_H > # include <sys/socket.h> > #elif HAVE_WINSOCK2_H > # include <winsock2.h> > #endif], > [gethostbyname("");], > gl_cv_func_gethostbyname=yes) > if test "$gl_cv_func_gethostbyname" != yes; then > am_save_LIBS="$LIBS" > LIBS="$LIBS -lwsock32" > AC_TRY_LINK([ > #if HAVE_SYS_SOCKET_H > # include <sys/socket.h> > #elif HAVE_WINSOCK2_H > # include <winsock2.h> > #endif], > [gethostbyname("");], > gl_cv_lib_gethostbyname=yes > gl_cv_func_gethostbyname=yes) > LIBS="$am_save_LIBS" > fi > ]) > > Bruno _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib