[Top][All Lists]

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

Re: Why configure failed to search libws2_32.a in MinGW+MSYS ?

From: Václav Zeman
Subject: Re: Why configure failed to search libws2_32.a in MinGW+MSYS ?
Date: Sat, 28 Dec 2013 09:00:15 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 12/28/2013 05:15 AM, Guo Leaveye wrote:
> Thanks a lot for your tip.
> Acoording to the log file, it just compiles a source code like this, I only 
> keep the lines matters.
>     char WSAGetLastError ();
>     int
>     main ()
>     {
>     return WSAGetLastError ();
>     }
> When compiling this simple source, GCC reports a error that "undefined 
> reference to `WSAGetLastError'", even though there is a linker option 
> "-lws2_32". I tried to replace the declaration of WSAGetLastError() with 
> includes of windows.h and winsock2.h, then it works. I have no idea on this 
> behaviour, that why linking the same library leads different result. Is there 
> any advice ?

The problem here is that without including windows.h or winsock2.h the
compiler does not see the function declaration and the one declaration
it supplies is wrong for the function. It is wrong because Win32 API is
using the stdcall calling convention which means the function name is

> An underscore (_) is prefixed to the name. The name is followed by the at 
> sign (@) followed by the number of bytes (in decimal) in the argument list. 
> Therefore, the function declared as int func( int a, double b ) is decorated 
> as follows: address@hidden

So, instead of using AC_CHECK_LIB, you will need to craft something of
your own that will add the headers includes to the test source.


Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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