what did i do wrong? c++ network

starting a basic first networking program. Can't figure out where did I go wrong

here is the VPNServer.h file
1
2
3
4
5
6
class VPNServer
{
public:
	bool init();
private:
};


here is the VPNServer.cpp file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <winsock2.h>
#include <iostream>
#include <string>
#include "VPNServer.h"

using namespace std;

bool VPNServer::init()
{
	WSAData wsaData;
	WORD wVersionRequested = MAKEWORD(2, 2);
	if (WSAStartup(wVersionRequested, &wsaData) != 0)
		return false;
	return true;
}


the error I'm getting:

Error	1	error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function "public: bool __thiscall VPNServer::init(void)" (?init@VPNServer@@QAE_NXZ)	VPNServer.obj	VPNServer


please help me figure it out. It's so basic I'm even ashamed to ask this but just can't figure out what did I do wrong...
Thanks
Looks like you haven't properly linked the library to your project.
any idea how I can fix this? I literally tried replacing everything possible and nothing helped
nvm got it fixed i forgot to add the lib
#pragma comment(lib, "Ws2_32.lib")
It'll be a little different depending on your IDE, but basically you need to make sure your search directories are pointing to the directory that stores the correct header files. Then you need to go in and make sure the linking flags are set to properly link in the library.

If you've done a bunch of messing around, I'd go back and reset everything and start from scratch.
Topic archived. No new replies allowed.