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 decorated: > 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: _func@12 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. -- VZ
Attachment:
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx https://lists.gnu.org/mailman/listinfo/autoconf