Search code examples
c++functionmfcdialoglnk2019

Unresolved Link Error


I'm receiving this error when I try and compile.

error LNK2019: unresolved external symbol "public: void __thiscall Serial::WritePort(char * const)" (?WritePort@Serial@@QAEXQAD@Z) referenced in function "public: void __thiscall CThermotronDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CThermotronDlg@@QAEXXZ)

I have included all the required header files but when I attempt to call the my WritePort function(located in my sConfig.cpp) in my main dialog.cpp I get this link error. Also every .cpp file is in the same folder so I'm not trying to reference files in different locations below is the for the WritePort Function and the block where it is being called.

WritePort

void WritePort(char buffer[])
{

HANDLE sSerial = CreateFile(L"COM3",GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,0,0);
OpenPort();
DWORD bytes;
WriteFile(sSerial, buffer,sizeof(buffer),&bytes,NULL);
}

Block

void CThermotronDlg::OnBnClickedButton2()

{

CString str; str.Format(L"%d",Index);
LPTSTR Dwell = new TCHAR[1000];
USES_CONVERSION;
char* buffer =T2A(Dwell);
MyListEx.GetItemText(Index,1,Dwell,1000);

Serial Port;
Port.WritePort(buffer);


AfxMessageBox(Dwell,MB_OK,NULL);

}


Solution

  • Shouldn't

    void WritePort(char buffer[])
    

    be

    void Serial::WritePort(char buffer[])
    

    ?