我在嘗試編譯時遇到此錯誤。無法解析的鏈接錯誤
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