【发布时间】:2012-06-13 04:32:13
【问题描述】:
第一次在这里发帖,因为我被我出色的 C++ 函数困住了。
我得到的错误是链接器错误,如下所示:
main.obj : error LNK2019: unresolved external symbol "public: void thiscall controls::printText(int,int,int,int,int,char const *,struct HWND *)" ( ?printText@controls@@QAEXHHHHHPBDPAUHWND__@@@Z) 在函数“long stdcall WndProc(struct HWND *,unsigned int,unsigned int,long)”(?WndProc@@YGJPAUHWND__@@IIJ@ Z)
C:\Users\HIDDEN\Documents\Visual Studio 2010\Projects\TimedShutdown\Debug\TimedShutdown.exe : 致命 >error LNK1120: 1 unresolved externals
基本上,我正在尝试创建一个用于创建 win32 控件和绘制文本的类,而绘制文本的功能是我的问题所在。
代码如下:
controls.h 文件段:-
void printText( int R, int G, int B, int x, int y, LPCSTR text, HWND parent);
controls.cpp 段
void printText(int R, int G, int B, int x, int y, LPCSTR text, HWND parent)
{
HDC hdc;
PAINTSTRUCT pss;
hdc = BeginPaint(parent, &pss);
SetBkMode(hdc, TRANSPARENT);
SetTextColor(hdc, RGB(R,G,B));
TextOut(hdc, 30, 20, text, strlen(text));
EndPaint(parent, &pss);
}
main.cpp 调用
controls ctrls;
ctrls->printText(255,0,0,300,50,"Test text",hWnd);
我已删除呼叫,但错误仍然存在。最初我也尝试将 HDC 和 PAINTSTRUCT 传递给该函数,但我在尝试识别错误源时已将其删除。
我完全迷路了,我不是一个了不起的 C++ 程序员,但我正在学习中。
批评我,我要求!
提前感谢您提供的任何帮助,非常感谢:)
【问题讨论】:
标签: c++ function linker arguments linker-errors