Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined reference to `TextOutA@20' [duplicate]

I am kind of stuck on this and would appreciate help in solving this please. I am using window GDI, and according to this link, including windows.h is what is needed to work with the TextOut function, among others, but I am still getting some undefined reference error messages and I am stuck.

**undefined reference to `TextOutA@20'|

undefined reference to `CreateDCA@16'|

undefined reference to `Escape@20'|

undefined reference to `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;
}
like image 982
Kobojunkie Avatar asked Dec 29 '11 06:12

Kobojunkie


1 Answers

Linking to gdi32.lib should solve the problem. :)

like image 64
Marlon Avatar answered Nov 06 '22 09:11

Marlon