[Xcb] [PATCH] Link with winsock library for socket functions on MinGW

Josh Triplett josh at joshtriplett.org
Sat Jul 4 12:14:31 PDT 2015


On Sat, Jul 04, 2015 at 03:09:26PM +0100, Jon TURNEY wrote:
> On 04/07/2015 14:31, Uli Schlachter wrote:
> >Am 17.03.2015 um 18:49 schrieb Jon TURNEY:
> >>Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
> >>---
> >>  configure.ac | 9 +++++++++
> >>  1 file changed, 9 insertions(+)
> >>
> >>diff --git a/configure.ac b/configure.ac
> >>index 6e7e9c3..cce0ddb 100644
> >>--- a/configure.ac
> >>+++ b/configure.ac
> >>@@ -206,6 +206,15 @@ case $host_os in
> >>          ;;
> >>  esac
> >>
> >>+dnl Link with winsock for socket functions on MinGW
> >>+case $host_os in
> >>+        *mingw*)
> >>+                AC_CHECK_LIB([ws2_32],[main])
> >
> >Why "main"?
> >
> >You should use a function for this test that is really part of ws2_32.
> 
> That would be ideal.
> 
> Unfortunately, it's a relatively long-standing issue with autoconf that
> AC_CHECK_LIB cannot find functions which don't use the default calling
> convention.
> 
> In this case, ws2_32, like most Windows system libraries, uses the stdcall
> calling convention.

Doesn't looking for main mean you'll find *any* library named ws2_32?
Granted, there's unlikely to be such a library on mingw that doesn't
have what you need.

There are more general autoconf tests that let you supply C source to
try compiling and linking; see AC_LINK_IFELSE at
https://www.gnu.org/software/autoconf/manual/autoconf-2.65/html_node/Running-the-Linker.html
and note the mention of it to implement AC_CHECK_LIB.  So you could
write a test that would actually find WSAStartup.

- Josh Triplett


More information about the Xcb mailing list