ok, i made two functions that do one of these two things, get a IpAddress and MacAddress.
i googled for help on creating these functions but now i got a problem which is they give me this problem:
1>NetworCPP.obj : error LNK2019: unresolved external symbol _gethostname@8 referenced in function "public: char * __thiscall CNetwork::CNetTool::MyIpAddress(void)" (?MyIpAddress@CNetTool@CNetwork@@QAEPADXZ)
1>NetworCPP.obj : error LNK2019: unresolved external symbol _GetAdaptersInfo@8 referenced in function "public: char * __thiscall CNetwork::CNetTool::GetMacAddress(void)" (?GetMacAddress@CNetTool@CNetwork@@QAEPADXZ)
these are in my Networking.cpp and been defined in a header which their class.
this is their code;
char* CNetTool::MyIpAddress()
{
static char buf[16];
gethostname(buf, 16);
return buf;
}
char* CNetTool::GetMacAddress()
{
static char retval[20];
IP_ADAPTER_INFO AdapterInfo[16];
DWORD dwBufLen = sizeof(AdapterInfo);
DWORD dwStatus = GetAdaptersInfo(AdapterInfo, &dwBufLen);
assert(dwStatus == ERROR_SUCCESS);
PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;
if(pAdapterInfo)
{
sprintf_s(retval, "%02X-%02X-%02X-%02X-%02X-%02X", AdapterInfo->Address[0], AdapterInfo->Address[1],AdapterInfo->Address[2],AdapterInfo->Address[3], AdapterInfo->Address[4], AdapterInfo->Address[5]);
} else retval[0]= '\0';
return retval;
}
their defined
class CNetTool
{
public:
char* BroadCastIp();
char* MyIpAddress();
char* GetMacAddress();
bool IsNetConnected();
char* StringIpAddress(char* IpPart1,char* IpPart2,char* IpPart3,char* IpPart4);
char* GetPartOfIp(char* Str,int Part);
};
i have set code generation to /MT so i can make sense.
questions?
1 - what can i do to fix it
2 - why does this error
Problem Solution That Never Fails: "Build A Bridge And Get Over It"