Member Avatar for Geek-Master

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.

Recommended Answers

All 4 Replies

Did you link to wsock32.lib?

Member Avatar for Geek-Master

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.

Member Avatar for Geek-Master

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.