c++ - Unresolved 链接错误

标签 c++ function mfc dialog lnk2019

<分区>

我在尝试编译时收到此错误。

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)

我已经包含了所有必需的头文件,但是当我尝试在我的主 dialog.cpp 中调用我的 WritePort 函数(位于我的 sConfig.cpp 中)时,我收到此链接错误。此外,每个 .cpp 文件都在同一个文件夹中,因此我不会尝试引用不同位置的文件,下面是 WritePort 函数和调用它的 block 。

写端口

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

最佳答案

不应该

void WritePort(char buffer[])

成为

void Serial::WritePort(char buffer[])

?

关于c++ - Unresolved 链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14733713/

相关文章:

c++ - 指针互换性与具有相同地址

c - 从函数返回结构

c++ - 代码在 WinDbg 上运行良好,但没有它就很奇怪

c++ - 在用 C++ 编写的解释器中处理内置函数的好方法是什么?

c++ - 无法让线程在 C++ 中工作?

c++ - 合并两个几乎相同的类模板

php - 是否可以在 Silverstripe 模板变量上运行一个函数来格式化输出?

function - 从函数返回函数以及为什么省略括号?

visual-studio - 在mfc中如何将控件置于前面

c++ - 逐行解析 CMemFile 中的文本