我在尝试编译时遇到此错误。无法解析的链接错误
error LNK2019: unresolved external symbol "public: void __thiscall Serial::WritePort(char * const)" ([email protected]@@[email protected]) referenced in function "public: void __thiscall CThermotronDlg::OnBnClickedButton2(void)" ([email protected]@@QAEXXZ)
我已经包括了所有必需的头文件,但是当我试图打电话给我写端口功能(位于我sConfig.cpp)在我的主dialog.cpp我得到这个链接错误。同样,每个.cpp文件都在同一个文件夹中,所以我不想在下面的不同位置引用文件,就是用于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);
}
块
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);
}
有些东西告诉我看到'Serial'的实现,或者更重要的是,任何'Serial :: WritePort'实现(注意类限定符)的代码缺少会导致您遇到问题及其最终解决方案。 – WhozCraig