|
From: Michael G. <mg...@te...> - 2006-08-25 05:39:18
|
> I have a small c program that calls getaddrinfo and freeaddrinfo. >=20 > I have the header file included for ws2tcpip.h. >=20 > When I compile with > gcc -Wall -o prog main.c -lws2_32 >=20 > I get warnings about implicit declarations of the 2 functions and > undefined references to the 2 functions from the linker. >=20 > In the ws2tcpip.h I see > #if (_WIN32_WINNT >=3D 0x0501) >=20 > ---declaration of getaddrinfo >=20 > #else > /* FIXME ... >=20 > When I print the value of _WIN32_WINNT I get 0x400 so obviously the > function isn't declared. That explains the implicit declarations > warning. But what about the undefined references? The functions are in > the library ws2_32.a. >=20 > What do I need to do to resolve this? Is it a MinGW version or a > Windows version that needs updating? Or something completely different? The lib you link to by providing -lws2_32 is an importlib. Whether that contains the required functions of not is pretty irrelevant. The question is: Does your OS provide them (you didn't tell us the OS you are using). Search MSDN for these functions to check which OS versions support them, thereby finding out whether your particular environment provides them. If it doesn't you see why it is wise MinGW is conservative here. If it does then define WINVER (not _WIN32_WINNT unless you know what you are doing) to 0x0501 at the top of your program. =46YI this and a few other constants are defined in windef.h. HTH, best, Michael =2D-=20 Vote against SPAM - see http://www.politik-digital.de/spam/ Michael Gerdau email: mg...@te... GPG-keys available on request or at public keyserver |