12 Dec 2011
If you’re encountering the error “Undefined reference to getaddrinfo()” he’s how to solve the problem. It seems the winsock examples on the MSDN site are very much intended for use with Visual C and therefore you may have to do a few additional things to get everything working correctly.
Firstly you’ll need to add a few Link Settings. In codeblocks you can find the settings page shown below under Project/Build Options/Link Settings.
As you can see above, you need to add “libws2_32.a” to the Link Libraries and “-lwsock32″ to the linker options.
You may need to add the following to your code: