[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: conditionally linking to mingw32 library
From: |
Mark Brand |
Subject: |
Re: conditionally linking to mingw32 library |
Date: |
Fri, 03 Jun 2005 12:52:48 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050511 |
Alexandre Duret-Lutz wrote:
>>>>"Mark" == Mark Brand <address@hidden> writes:
>>>>
>
>[...]
>
> Mark> <configure.ac>
> Mark> if test x$target_os == xmingw32; then
> Mark> WINSOCK=-lws2_32
> Mark> fi
> Mark> AC_SUBST(WINSOCK)
> Mark> </configure.ac>
>
>Eww. That would be $host, not $target, and anyway testing the
>host type should always be your last resort. Why not test for
>the presence of the ws2_32 library and use it if it's there ?
>
>Here is a possible check assuming adding -lws2_32 to LIBS is OK
>(but it's easy to define WINSOCK as above if you prefer).
>
>
>AC_SEARCH_LIBS([gethostbyname], [nsl socket], [], [
>dnl Can't search ws2_32 for gethostbyname using AC_SEARCH_LIBS, because
>dnl it requires #include <winsocks2.h> to work.
>my_old_LIBS=$LIBS
>LIBS="-lws2_32 $LIBS"
>ws2_res=yes
>AC_MSG_CHECKING([for gethostbyname in ws2_32])
>AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <winsock2.h>]],
> [[gethostbyname ("");]])],
> [], [LIBS=$my_ac_save_LIBS ws2_res=no])
>AC_MSG_RESULT([$ws2_res])
>])
>
I found my obvious and fundamental mistake. In configure.ac, my
AC_OUTPUT line came before the AC_SEARCH_LIBS. Studying the generated
configure script made this clear. Thanks very much for your help.
Mark