bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] getaddrinfo: finding gethostbyname in mingw32


From: Bruno Haible
Subject: Re: [bug-gnulib] getaddrinfo: finding gethostbyname in mingw32
Date: Wed, 18 Jan 2006 14:50:21 +0100
User-agent: KMail/1.5

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.)
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:

  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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]