I'm trying to use WinSock.h header file, but I get either one of the errors below: in VS2010 (C++):
Unresolved External Symbol to [the function included in winsock.g, e.g socket()]
in gcc command line (C):
Undefined Reference to [the function included in winsock.g, e.g socket()]
code is simple: Just including the Winsock.h header file and then
SOCKET s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
I get an error on socket()
& closesocket()
functions...!
I searched in Stackoverflow and found several topics over this, but they all suggested a change in the header file. I can't change WinSock.h here, so I need a solution in the actual code that uses the header file. Any ideas?
According to the documentation, you need ws2_32.lib
.
Go to Project->Properties->Linker->Additional dependencies and add ws2_32.lib
.
EDIT:
That should be Project->Properties->Linker->Input->Additional Dependencies