[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 11:11:06 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050511 |
>>>>"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 agree that this is a more elegant solution. Thanks.
"my_old_LIBS" and "my_ac_save_LIBS" were meant to be the same variable,
right?
Thanks. Even though "./configure --with-msw --target=i586-mingw32msvc
--host=i586-mingw32msvc --build=i386-linux" reports that that it finds
gethostbyname in ws2_32, the generated Makefile has a line:
LIBS =
I must be missing something obvious.
Mark