I have a C program that uses getaddrinfo()
. It works as expected on Linux and Mac OS X.
I'm in the middle of porting it to Windows.
When I compile it (with MinGW gcc) I get the following warnings:
ext/socket/socket.c: In function 'sl_tcp_socket_init':
ext/socket/socket.c:98:5: warning implicit declaration of function 'getaddrinfo' [-Wimplicit-function-declaration]
ext/socket/socket.c:104:9: warning implicit declaration of function 'freeaddrinfo' [-Wimplicit-function-declaration]
Then the entire thing fails to link with undefined references to getaddrinfo()
and freeaddrinfo()
.
Now, according to this MSDN page, getaddrinfo()
is supported on Windows and is located in the header file Ws2tcpip.h
and the library file Ws2_32.lib
.
I'm including Ws2tcpip.h
and linking with -lWs2_32
, so I'm not sure why this isn't working.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…