2013-02-06 131 views
0

我在嘗試編譯時遇到此錯誤。無法解析的鏈接錯誤

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); 

}

+1

有些東西告訴我看到'Serial'的實現,或者更重要的是,任何'Serial :: WritePort'實現(注意類限定符)的代碼缺少會導致您遇到問題及其最終解決方案。 – WhozCraig

回答

2

不應該

void WritePort(char buffer[]) 

void Serial::WritePort(char buffer[]) 

+0

謝謝你我真是個白癡。 – user1704863

1

功能WritePort需要是Serial類的一部分,如您正在使用它作爲Port.WritePort(buffer)而不是WritePort(buffer)

void Serial::WritePort(char buffer[]) 
{ 
bool umm; 
HANDLE sSerial = CreateFile(L"COM3",GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,0,0); 
OpenPort(); 
DWORD bytes; 
umm = WriteFile(sSerial, buffer,sizeof(buffer),&bytes,NULL); 
} 
相關問題