2013-02-06 122 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); 
} 
相关问题