Thread overview
Graphical command not recognized
Sep 17, 2004
Peter Reid
Sep 17, 2004
Bastiaan Veelo
Sep 17, 2004
J C Calvarese
Sep 17, 2004
Helmut Leitner
Sep 18, 2004
Peter Reid
Sep 18, 2004
Toaster
Sep 18, 2004
Peter Reid
September 17, 2004
I'm having trouble compiling code with commands such as TextOut, MoveToEx, LineTo, Ellipse, etc. As far as I can tell, it's every graphical drawing command except DrawText. I don't have the compiler with me here, but I'm pretty sure the error message is something like 'Undefined symbol: LineTo'. If someone could tell me what I'm doing wrong, that would be great.

Thanks in advance.


September 17, 2004
You are not mentioning where you get these functions from; some UI library I presume. If you get an undefined symbol error, it generally means you need to compile and link in the appropriate module(s).

Bastiaan.

Peter Reid wrote:
> I'm having trouble compiling code with commands such as TextOut, MoveToEx,
> LineTo, Ellipse, etc. As far as I can tell, it's every graphical drawing command
> except DrawText. I don't have the compiler with me here, but I'm pretty sure the
> error message is something like 'Undefined symbol: LineTo'. If someone could
> tell me what I'm doing wrong, that would be great.
> 
> Thanks in advance.
> 
> 
September 17, 2004
Bastiaan Veelo wrote:
> You are not mentioning where you get these functions from; some UI library I presume. If you get an undefined symbol error, it generally means you need to compile and link in the appropriate module(s).
> 
> Bastiaan.

Or you might need to "import" a module.

Come on, give us some hints, toss us some code, splash an error message at us, throw us a bone...

> 
> Peter Reid wrote:
> 
>> I'm having trouble compiling code with commands such as TextOut, MoveToEx,
>> LineTo, Ellipse, etc. As far as I can tell, it's every graphical drawing command
>> except DrawText. I don't have the compiler with me here, but I'm pretty sure the
>> error message is something like 'Undefined symbol: LineTo'. If someone could
>> tell me what I'm doing wrong, that would be great.
>>
>> Thanks in advance.


-- 
Justin (a/k/a jcc7)
http://jcc_7.tripod.com/d/
September 17, 2004

Peter Reid wrote:
> 
> I'm having trouble compiling code with commands such as TextOut, MoveToEx, LineTo, Ellipse, etc. As far as I can tell, it's every graphical drawing command except DrawText. I don't have the compiler with me here, but I'm pretty sure the error message is something like 'Undefined symbol: LineTo'. If someone could tell me what I'm doing wrong, that would be great.
> 
> Thanks in advance.

These are all functions from the Win32 C-API. To use them you must import a module that declares these functions and link for Windows.

The FAQ may help:

  <http://www.wikiservice.at/wiki4d/wiki.cgi?FaqRoadmap#HowtocallaWindowsAPIfunction>

AFAIK there is currently no module in the Phobos standard library that defines them all. std.c.windows.windows.d contains some of them.

Pavel had a much more complete windows.d module that I used a while ago.

I do not know the current state of affairs.

-- 
Helmut Leitner    leitner@hls.via.at
Graz, Austria   www.hls-software.com
September 18, 2004
Thanks for the replies. Firstly, here are the specifics that I have now been able to gather.

Here are my errors:

hello.obj(hello)
Error 42: Symbol Undefined _LineTo@12
hello.obj(hello)
Error 42: Symbol Undefined _MoveToEx@16


Here is my entire code:
or: J C Calvarese

#include <windows.h>
#include <stdio.h>
const char g_szClassName[] = "myWindowClass";

// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_PAINT:
HDC     hDC;
PAINTSTRUCT ps;
hDC = BeginPaint(hwnd, &ps);
MoveToEx(hDC, 0, 0, NULL);
LineTo(hDC, 50, 50);
EndPaint(hwnd, &ps);
return 0;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_LBUTTONUP:
//MessageBox(NULL, "RESIZED!!!1111oneone", "Note", MB_OK);
break;
case WM_KEYDOWN:
char myString[100];
sprintf(myString, "X: %i", (int) wParam);
MessageBox(NULL, myString  , "Note", MB_OK);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;

//Step 1: Registering the Window Class
wc.cbSize        = sizeof(WNDCLASSEX);
wc.style         = 0;
wc.lpfnWndProc   = WndProc;
wc.cbClsExtra    = 0;
wc.cbWndExtra    = 0;
wc.hInstance     = hInstance;
wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName  = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}

// Step 2: Creating the Window
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"The title of my window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
NULL, NULL, hInstance, NULL);

if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}

ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);

// Step 3: The Message Loop
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}



I tried adding the following, based on Helmut Leitner's link. I got lots of errors, so I'm assuming I did something wrong.

extern (Windows) BOOL LineTo(
HDC hdc,    // device context handle
int nXEnd,  // x-coordinate of ending point
int nYEnd   // y-coordinate of ending point
);

extern (Windows) BOOL MoveToEx(
HDC hdc,          // handle to device context
int X,            // x-coordinate of new current position
int Y,            // y-coordinate of new current position
LPPOINT lpPoint   // old current position
);

The FAQ he linked to said this: "and add kernel32.lib to your linker command." Could someone please clarify how to do that? I haven't been able to find anything through searches.

In article <414A7BA5.D7543519@wikiservice.at>, Helmut Leitner says...
>
>
>
>Peter Reid wrote:
>> 
>> I'm having trouble compiling code with commands such as TextOut, MoveToEx, LineTo, Ellipse, etc. As far as I can tell, it's every graphical drawing command except DrawText. I don't have the compiler with me here, but I'm pretty sure the error message is something like 'Undefined symbol: LineTo'. If someone could tell me what I'm doing wrong, that would be great.
>> 
>> Thanks in advance.
>
>These are all functions from the Win32 C-API. To use them you must import a module that declares these functions and link for Windows.
>
>The FAQ may help:
>
>  <http://www.wikiservice.at/wiki4d/wiki.cgi?FaqRoadmap#HowtocallaWindowsAPIfunction>
>
>AFAIK there is currently no module in the Phobos standard library that defines them all. std.c.windows.windows.d contains some of them.
>
>Pavel had a much more complete windows.d module that I used a while ago.
>
>I do not know the current state of affairs.
>
>-- 
>Helmut Leitner    leitner@hls.via.at
>Graz, Austria   www.hls-software.com


September 18, 2004
Looks like you chose the wrong mailing list, since you are writing a C program and this is about the D language. But since you are here, take a look at  the D Language, http://www.digitalmars.com/d/ - you might find it interesting.

Your problem is a linking problem. The compiler already compiled your program into the hello.obj object file and now it tries to link it together with the API functions you referenced. That means your code already compiles, what you need to do is to link in the right libraries.


On Sat, 18 Sep 2004 00:51:25 +0000 (UTC), Peter Reid
<Peter_member@pathlink.com> wrote:

>Thanks for the replies. Firstly, here are the specifics that I have now been able to gather.
>
>Here are my errors:
>
>hello.obj(hello)
>Error 42: Symbol Undefined _LineTo@12
>hello.obj(hello)
>Error 42: Symbol Undefined _MoveToEx@16
>
>
>Here is my entire code:
>or: J C Calvarese
>
>#include <windows.h>
>#include <stdio.h>
>const char g_szClassName[] = "myWindowClass";
>
>// Step 4: the Window Procedure
>LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
>{
>switch(msg)
>{
>case WM_PAINT:
>HDC     hDC;
>PAINTSTRUCT ps;
>hDC = BeginPaint(hwnd, &ps);
>MoveToEx(hDC, 0, 0, NULL);
>LineTo(hDC, 50, 50);
>EndPaint(hwnd, &ps);
>return 0;
>case WM_CLOSE:
>DestroyWindow(hwnd);
>break;
>case WM_LBUTTONUP:
>//MessageBox(NULL, "RESIZED!!!1111oneone", "Note", MB_OK);
>break;
>case WM_KEYDOWN:
>char myString[100];
>sprintf(myString, "X: %i", (int) wParam);
>MessageBox(NULL, myString  , "Note", MB_OK);
>break;
>case WM_DESTROY:
>PostQuitMessage(0);
>break;
>default:
>return DefWindowProc(hwnd, msg, wParam, lParam);
>}
>return 0;
>}
>
>int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
>LPSTR lpCmdLine, int nCmdShow)
>{
>WNDCLASSEX wc;
>HWND hwnd;
>MSG Msg;
>
>//Step 1: Registering the Window Class
>wc.cbSize        = sizeof(WNDCLASSEX);
>wc.style         = 0;
>wc.lpfnWndProc   = WndProc;
>wc.cbClsExtra    = 0;
>wc.cbWndExtra    = 0;
>wc.hInstance     = hInstance;
>wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
>wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
>wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
>wc.lpszMenuName  = NULL;
>wc.lpszClassName = g_szClassName;
>wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
>
>if(!RegisterClassEx(&wc))
>{
>MessageBox(NULL, "Window Registration Failed!", "Error!",
>MB_ICONEXCLAMATION | MB_OK);
>return 0;
>}
>
>// Step 2: Creating the Window
>hwnd = CreateWindowEx(
>WS_EX_CLIENTEDGE,
>g_szClassName,
>"The title of my window",
>WS_OVERLAPPEDWINDOW,
>CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
>NULL, NULL, hInstance, NULL);
>
>if(hwnd == NULL)
>{
>MessageBox(NULL, "Window Creation Failed!", "Error!",
>MB_ICONEXCLAMATION | MB_OK);
>return 0;
>}
>
>ShowWindow(hwnd, nCmdShow);
>UpdateWindow(hwnd);
>
>// Step 3: The Message Loop
>while(GetMessage(&Msg, NULL, 0, 0) > 0)
>{
>TranslateMessage(&Msg);
>DispatchMessage(&Msg);
>}
>return Msg.wParam;
>}
>
>
>
>I tried adding the following, based on Helmut Leitner's link. I got lots of errors, so I'm assuming I did something wrong.
>
>extern (Windows) BOOL LineTo(
>HDC hdc,    // device context handle
>int nXEnd,  // x-coordinate of ending point
>int nYEnd   // y-coordinate of ending point
>);
>
>extern (Windows) BOOL MoveToEx(
>HDC hdc,          // handle to device context
>int X,            // x-coordinate of new current position
>int Y,            // y-coordinate of new current position
>LPPOINT lpPoint   // old current position
>);
>
>The FAQ he linked to said this: "and add kernel32.lib to your linker command." Could someone please clarify how to do that? I haven't been able to find anything through searches.
>
>In article <414A7BA5.D7543519@wikiservice.at>, Helmut Leitner says...
>>
>>
>>
>>Peter Reid wrote:
>>> 
>>> I'm having trouble compiling code with commands such as TextOut, MoveToEx, LineTo, Ellipse, etc. As far as I can tell, it's every graphical drawing command except DrawText. I don't have the compiler with me here, but I'm pretty sure the error message is something like 'Undefined symbol: LineTo'. If someone could tell me what I'm doing wrong, that would be great.
>>> 
>>> Thanks in advance.
>>
>>These are all functions from the Win32 C-API. To use them you must import a module that declares these functions and link for Windows.
>>
>>The FAQ may help:
>>
>>  <http://www.wikiservice.at/wiki4d/wiki.cgi?FaqRoadmap#HowtocallaWindowsAPIfunction>
>>
>>AFAIK there is currently no module in the Phobos standard library that defines them all. std.c.windows.windows.d contains some of them.
>>
>>Pavel had a much more complete windows.d module that I used a while ago.
>>
>>I do not know the current state of affairs.
>>
>>-- 
>>Helmut Leitner    leitner@hls.via.at
>>Graz, Austria   www.hls-software.com
>

September 18, 2004
Woops, sorry about posting in the wrong forum. I though D was short for digital mars, I guess. Thanks for the help as well.

In article <7e2ok0dacds7jikdusupqsqoor7qqs2akt@4ax.com>, Toaster says...
>
>
>Looks like you chose the wrong mailing list, since you are writing a C program and this is about the D language. But since you are here, take a look at  the D Language, http://www.digitalmars.com/d/ - you might find it interesting.
>
>Your problem is a linking problem. The compiler already compiled your program into the hello.obj object file and now it tries to link it together with the API functions you referenced. That means your code already compiles, what you need to do is to link in the right libraries.
>
>
>On Sat, 18 Sep 2004 00:51:25 +0000 (UTC), Peter Reid
><Peter_member@pathlink.com> wrote:
>
>>Thanks for the replies. Firstly, here are the specifics that I have now been able to gather.
>>
>>Here are my errors:
>>
>>hello.obj(hello)
>>Error 42: Symbol Undefined _LineTo@12
>>hello.obj(hello)
>>Error 42: Symbol Undefined _MoveToEx@16
>>
>>
>>Here is my entire code:
>>or: J C Calvarese
>>
>>#include <windows.h>
>>#include <stdio.h>
>>const char g_szClassName[] = "myWindowClass";
>>
>>// Step 4: the Window Procedure
>>LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
>>{
>>switch(msg)
>>{
>>case WM_PAINT:
>>HDC     hDC;
>>PAINTSTRUCT ps;
>>hDC = BeginPaint(hwnd, &ps);
>>MoveToEx(hDC, 0, 0, NULL);
>>LineTo(hDC, 50, 50);
>>EndPaint(hwnd, &ps);
>>return 0;
>>case WM_CLOSE:
>>DestroyWindow(hwnd);
>>break;
>>case WM_LBUTTONUP:
>>//MessageBox(NULL, "RESIZED!!!1111oneone", "Note", MB_OK);
>>break;
>>case WM_KEYDOWN:
>>char myString[100];
>>sprintf(myString, "X: %i", (int) wParam);
>>MessageBox(NULL, myString  , "Note", MB_OK);
>>break;
>>case WM_DESTROY:
>>PostQuitMessage(0);
>>break;
>>default:
>>return DefWindowProc(hwnd, msg, wParam, lParam);
>>}
>>return 0;
>>}
>>
>>int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
>>LPSTR lpCmdLine, int nCmdShow)
>>{
>>WNDCLASSEX wc;
>>HWND hwnd;
>>MSG Msg;
>>
>>//Step 1: Registering the Window Class
>>wc.cbSize        = sizeof(WNDCLASSEX);
>>wc.style         = 0;
>>wc.lpfnWndProc   = WndProc;
>>wc.cbClsExtra    = 0;
>>wc.cbWndExtra    = 0;
>>wc.hInstance     = hInstance;
>>wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
>>wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
>>wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
>>wc.lpszMenuName  = NULL;
>>wc.lpszClassName = g_szClassName;
>>wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
>>
>>if(!RegisterClassEx(&wc))
>>{
>>MessageBox(NULL, "Window Registration Failed!", "Error!",
>>MB_ICONEXCLAMATION | MB_OK);
>>return 0;
>>}
>>
>>// Step 2: Creating the Window
>>hwnd = CreateWindowEx(
>>WS_EX_CLIENTEDGE,
>>g_szClassName,
>>"The title of my window",
>>WS_OVERLAPPEDWINDOW,
>>CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
>>NULL, NULL, hInstance, NULL);
>>
>>if(hwnd == NULL)
>>{
>>MessageBox(NULL, "Window Creation Failed!", "Error!",
>>MB_ICONEXCLAMATION | MB_OK);
>>return 0;
>>}
>>
>>ShowWindow(hwnd, nCmdShow);
>>UpdateWindow(hwnd);
>>
>>// Step 3: The Message Loop
>>while(GetMessage(&Msg, NULL, 0, 0) > 0)
>>{
>>TranslateMessage(&Msg);
>>DispatchMessage(&Msg);
>>}
>>return Msg.wParam;
>>}
>>
>>
>>
>>I tried adding the following, based on Helmut Leitner's link. I got lots of errors, so I'm assuming I did something wrong.
>>
>>extern (Windows) BOOL LineTo(
>>HDC hdc,    // device context handle
>>int nXEnd,  // x-coordinate of ending point
>>int nYEnd   // y-coordinate of ending point
>>);
>>
>>extern (Windows) BOOL MoveToEx(
>>HDC hdc,          // handle to device context
>>int X,            // x-coordinate of new current position
>>int Y,            // y-coordinate of new current position
>>LPPOINT lpPoint   // old current position
>>);
>>
>>The FAQ he linked to said this: "and add kernel32.lib to your linker command." Could someone please clarify how to do that? I haven't been able to find anything through searches.
>>
>>In article <414A7BA5.D7543519@wikiservice.at>, Helmut Leitner says...
>>>
>>>
>>>
>>>Peter Reid wrote:
>>>> 
>>>> I'm having trouble compiling code with commands such as TextOut, MoveToEx, LineTo, Ellipse, etc. As far as I can tell, it's every graphical drawing command except DrawText. I don't have the compiler with me here, but I'm pretty sure the error message is something like 'Undefined symbol: LineTo'. If someone could tell me what I'm doing wrong, that would be great.
>>>> 
>>>> Thanks in advance.
>>>
>>>These are all functions from the Win32 C-API. To use them you must import a module that declares these functions and link for Windows.
>>>
>>>The FAQ may help:
>>>
>>>  <http://www.wikiservice.at/wiki4d/wiki.cgi?FaqRoadmap#HowtocallaWindowsAPIfunction>
>>>
>>>AFAIK there is currently no module in the Phobos standard library that defines them all. std.c.windows.windows.d contains some of them.
>>>
>>>Pavel had a much more complete windows.d module that I used a while ago.
>>>
>>>I do not know the current state of affairs.
>>>
>>>-- 
>>>Helmut Leitner    leitner@hls.via.at
>>>Graz, Austria   www.hls-software.com
>>
>