I’m trying to get the hostname of the computer running my plugin with gethostname(char * name, int namelen) from winsock.h. I execute it in code like so:
Code:
#include "Player.h"
#include "winsock.h"
Player::Player(_bstr_t connectionString)
{
_connectionString = connectionString;
::CoInitialize(NULL);
_connectionPtr.CreateInstance(__uuidof(ADODB::Connection));
if(_connectionPtr)
{
_connectionPtr->Open(_connectionString, "", "", 0);
}
GetServerSettings(GetHostname());
}
char* Player::GetHostname()
{
char* name = "";
int nameLen = 50;
::gethostname(name, nameLen);
return name;
}
void Player::GetServerSettings(char * hostname)
{
ADODB::_RecordsetPtr recordsetPtr = Provider::GetServerSettings(_connectionPtr, hostname);
if(recordsetPtr && !recordsetPtr->EndOfFile)
{
_gameServerType = GameServerType(int(recordsetPtr->Fields->Item["GameServerType_ID"]->Value));
recordsetPtr->Close();
}
recordsetPtr->Release();
}
Player::~Player()
{
}
I’m getting:
Code:
Error 1 error LNK2019: unresolved external symbol _gethostname@8 referenced in function "private: char * __thiscall Player::GetHostname(void)" (?GetHostname@Player@@AAEPADXZ) Player.obj
How do I properly link to winsock.h?