[Top][All Lists]

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

AC_SEARCH_LIBS with appropriate system headers

From: Zack Weinberg
Subject: AC_SEARCH_LIBS with appropriate system headers
Date: Mon, 11 Jul 2011 16:23:46 -0700

The obvious way to detect that you're on MinGW and you need to stick
-lws2_32 on your link line for 'ntohl' is

    AC_SEARCH_LIBS([ntohl], [ws2_32])

but this does not work, because the system declares ntohl as

    WINSOCK_API_LINKAGE u_long PASCAL ntohl(u_long);

whereas AC_LANG_CALL will declare it as

    char ntohl();

On Windows the former gets the symbol name 'address@hidden' and the latter
just '_ntohl', which means both link attempts will fail.  There's no
way autoconf can be expected to know this, it has to include the
appropriate system header.  Worse, the "appropriate system header" is
different on Windows than on Unixy platforms.  Thus, to get it right
everywhere, the program compiled needs to be something like this:

    [#ifdef _WIN32
    #include <winsock2.h>
    #include <arpa/inet.h>
    [return (int)ntohl(42);])])

Is there a neater way to do this test than by copying the entire
definition of AC_SEARCH_LIBS into my (or my aclocal.m4)
and hacking it up?


reply via email to

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