Hey everyone, I'm working on my first program using "Winsock2.h".

I'm getting back linker errors "error LNK2001: unresolved external symbol ..."
9 unresolved externals total

The program came from an MSDN tutorial: "A simple winsock program", its a simple ping program that sends packets to a loopback address.

when I include winsock2.h I use

#include <stdio.h>         // for printf
#include "winsock2.h"

I'm sure its got something to do with define, but I've never worked with that in my programs before. If someone can point me to a tutorial, I'd be very happy. Thanks for viewing.

I googled for how to link a library and haven't found anything yet.
I'm using Visual Studio .NET for my C++ compiler. Some webpages that google turned up say that you can go into "Project" --> "Settings" --> "Linker" but there isn't a tab for settings under "Project". I guess thats a 6.0 thing and not a .NET thing.

I will be searching and google'n some more on how to link. I will also be checking up on here every now and then if you, Narue, have any info on how to link using .NET. Thanks for the help.

I searched on how to link Wsock32.LIB and found out how.

#include <stdio.h>        // for printf
#include "winsock2.h"

#pragma comment( lib, "wsock32.lib" )     // This will link to wsock32.lib

void main()
{
       // Winsock stuff
}

I just typed in that little line and bam... everything a...o...k.

This article has been dead for over six months. Start a new discussion instead.