|
From: James S. <jam...@op...> - 2006-08-25 06:31:55
|
On Fri, 2006-08-25 at 07:38 +0200, Michael Gerdau wrote: > > I have a small c program that calls getaddrinfo and freeaddrinfo. > > > > I have the header file included for ws2tcpip.h. > > > > When I compile with > > gcc -Wall -o prog main.c -lws2_32 > > > > I get warnings about implicit declarations of the 2 functions and > > undefined references to the 2 functions from the linker. > > > > In the ws2tcpip.h I see > > #if (_WIN32_WINNT >= 0x0501) > > > > ---declaration of getaddrinfo > > > > #else > > /* FIXME ... > > > > 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. > > > > 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. Ah ha. XP Pro is what the app will need to run on. > 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. > FYI this and a few other constants are defined in windef.h. Thanks for your help. Regards, James. |