I wanted to make a server application in C++ with Visual Studio 6. Although I included winsock2.h, ws2tcpip.h and ws2_32.lib in my cpp:
#include <winsock2.h> #include <ws2tcpip.h> #pragma comment(lib,"Ws2_32.lib")
I still was unable to build the project and got the errors:
Server.obj : error LNK2001: unresolved external symbol _freeaddrinfo@4 Server.obj : error LNK2001: unresolved external symbol _getaddrinfo@16
The getaddrinfo and freeaddrinfo functions were added to the Ws2_32.dll on Windows XP and later. Looking with the Dependency Walker indeed the functions were there. I thought then that the ws2_32.lib that came with Visual Studio 6.0 installation was too old. I hoped that the installation of the latest service pack for Visual Studio 6 can fix the problem, but it did not.
The solution was to get a newer version of the library and the ws2tcpip.h from a newer Visual Studio installation.