我有点坚持这一点,并希望得到帮助解决这个问题。我正在使用窗口GDI,根据这个链接,包括windows.h是使用TextOut函数所需要的,但我仍然得到一些未定义的引用错误消息,我被卡住了。
**未定义引用`TextOutA @ 20'|
对“CreateDCA @ 16”|
的未定义引用未定义引用`Escape @ 20'|
未定义引用`DeleteDC @ 4'| **
#include <Windows.h>// HDC is a typedef defined in the windows.h library
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include <strstream>
#include <string.h>
using namespace std;
#define IDM_QUIT 102
#define EXAMPLE 101
#define IDM_PRINT 27
#define IDM_SHOW 1
//this excerpt demonstrates how to get the handle to a device context ysing the BegingPaint() GDI function
long FAR PASCAL _export WINDOWPROCEDURE(HWND hwnd, UINT message, UINT wParam, LONG Param)
{
HDC hdc;
PAINTSTRUCT ps;
RECT area;
char PInfo[80]="";
char DriverName[20];
char DeviceName[40];
char Other[20];
int X,Y;
X=100;
Y=100;
switch(message)
{
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
TextOut(hdc,X,Y, "Speed of Light", 14);
EndPaint(hwnd, &ps);
case IDM_SHOW:
hdc = GetDC(hwnd);
TextOut(hdc, X,Y, "Speed of Light", 14);
ReleaseDC(hwnd, hdc);
case IDM_PRINT:
GetProfileString("windows", "device", "", PInfo,80);
istrstream In(PInfo);
In.getline(DeviceName, 80, ',');
In.getline(DriverName, 80, ',');
In.getline(Other,80, ',');
hdc = CreateDC(DriverName, DeviceName, Other, NULL);
Escape(hdc,
STARTDOC,8,
(LPSTR)"EXAMPLE",0L);
TextOut(hdc, X, Y, "Speed of Light", 14);
Escape(hdc, NEWFRAME, 0,0L, 0L);
Escape(hdc, ENDDOC, 0,0L, 0L);
DeleteDC(hdc);
}
return 0;
}
答案 0 :(得分:7)
链接到gdi32.lib应该可以解决问题。 :)
答案 1 :(得分:-2)
哦,朋友,如果您在dev cpp中遇到过这种类型的错误,请转到tool-&gt; compliler选项 - &gt; 点击设置标签 - &gt;链接器 - &gt;更改不要创建控制台窗口为“是” - &gt;点击确定。您的问题可能会得到解决。