Linking with Winsock

This is a discussion on Linking with Winsock within the Networking/Device Communication forums, part of the General Programming Boards category; Hey Using Visual C++ 6.0 I'm having problems with linking to the functions in winsock.h All I've done in the ...

  1. #1
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986

    Linking with Winsock

    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.

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    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")

  3. #3
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    Thanks very much, that worked perfectly!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Winsock issues
    By tjpanda in forum Windows Programming
    Replies: 3
    Last Post: 12-04-2008, 07:32 AM
  2. winsock linking problems
    By Calef13 in forum Windows Programming
    Replies: 2
    Last Post: 08-29-2007, 08:54 AM
  3. Winsock Messaging Program
    By Morgul in forum Windows Programming
    Replies: 13
    Last Post: 04-25-2005, 04:00 PM
  4. Where do I initialize Winsock and catch messages for it?
    By Lithorien in forum Windows Programming
    Replies: 10
    Last Post: 12-30-2004, 11:11 AM
  5. winsock
    By pode in forum Networking/Device Communication
    Replies: 2
    Last Post: 09-26-2003, 12:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21