Linking with Winsock [Archive] - C Board

PDA

View Full Version : Linking with Winsock


stovellp
07-08-2003, 08:18 PM
Hey

Using Visual C++ 6.0 I'm having problems with linking to the functions in winsock.h

All I've done in the file is #include <winsock.h>, and I get a good 7 or so errors during the linking stage that read:

main.obj : error LNK2001: unresolved external symbol _accept@12

and so on, fo all the different winsock functions. I figure I'm supposed to tell it to link with a winsock library somewhere, but I don't know where.

So all I need is for someone to tell me where to go to tell it to link with these functions, and what file I must link with, thanks.

Eibro
07-08-2003, 08:50 PM
For winsock 1.x: wsock32.lib
For winsock 2.x: ws2_32.lib

Add this line towards the head of your main cpp file: #pragma comment(lib, "wsock32.lib")

stovellp
07-08-2003, 09:40 PM
Thanks very much, that worked perfectly!