I'm compiling a win32 console application and i get these 2 strange errors:
C:\DOCUME~1\Dima\LOCALS~1\Temp\ccErbmlV.o: In function Z22AddSegmentAtMessagePosP5HDC(HWND__ *, int)':C:\Dev-Cpp\1Projects\Win32\templates\not_so_simple4.cpp:14 undefined reference toLineTo@12:
[Linker error] undefined reference to `MoveToEx@16'
here is the source code of the program:
i'm using version 4.9.9.2
can someone help me out
i tried adding -libgdi32, but it couldn't find it
so i added the libgdi32.a using "add library or object" button and it works fine.
thanks for the help, it really helped me out, i was about to quit on devc++
i have a question how do i know when to use theses linkers and libraries in my program??
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In answer to your bigger question, it can be challenging if you are
compiling code that someone else wrote. In general, looking at the
names of the header files that are included in your code, and the
functions that they contain can enable you to find the library you need.
Have your checked out the section in the thread "Please Read Before Posting
a Question" on the compile log, including headers, and linking libraries.
It might help provide some context.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm compiling a win32 console application and i get these 2 strange errors:
C:\DOCUME~1\Dima\LOCALS~1\Temp\ccErbmlV.o: In function
Z22AddSegmentAtMessagePosP5HDC(HWND__ *, int)':C:\Dev-Cpp\1Projects\Win32\templates\not_so_simple4.cpp:14 undefined reference to
LineTo@12:[Linker error] undefined reference to `MoveToEx@16'
here is the source code of the program:
i'm using version 4.9.9.2
can someone help me out
include <windows.h>
void AddSegmentAtMessagePos(HDC hDC, HWND hwnd, BOOL bDraw)
{
DWORD dwPos;
POINTS points;
POINT point;
dwPos = GetMessagePos();
points = MAKEPOINTS(dwPos);
point.x = points.x;
point.y = points.y;
ScreenToClient(hwnd, &point);
//DPtoLP(hDC, &point, 1);
if (bDraw){
LineTo(hDC, point.x, point.y);
}else{
MoveToEx(hDC, point.x, point.y, NULL);
}
}
void DrawHello(HWND hwnd)
{
HDC hDC;
MSG msg;
if (GetCapture() != NULL) return;
hDC = GetDC(hwnd);
if (hDC != NULL)
{
SetCapture(hwnd);
AddSegmentAtMessagePos(hDC, hwnd, FALSE);
while(GetMessage(&msg, NULL, 0, 0))
{
if (GetCapture() != hwnd) break;
switch (msg.message)
{
case WM_MOUSEMOVE:
AddSegmentAtMessagePos(hDC, hwnd, TRUE);
break;
case WM_LBUTTONUP:
goto ExitLoop;
default:
DispatchMessage(&msg);
}
}
ExitLoop:
ReleaseCapture();
ReleaseDC(hwnd, hDC);
}
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_LBUTTONDOWN:
DrawHello(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR d3, int nCmdShow)
{
MSG msg;
HWND hwnd;
WNDCLASS wndClass;
if (hPrevInstance == NULL)
{
memset(&wndClass, 0, sizeof(wndClass));
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.hInstance = hInstance;
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndClass.lpszClassName = "HELLO";
if (!RegisterClass(&wndClass)) return FALSE;
}
hwnd = CreateWindow("HELLO", "HELLO",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg, NULL, 0, 0))
DispatchMessage(&msg);
return msg.wParam;
}
add -libgdi32 to the linker options (libgdi32.a)
You mean:
-lgdi32
Clifford
i tried adding -libgdi32, but it couldn't find it
so i added the libgdi32.a using "add library or object" button and it works fine.
thanks for the help, it really helped me out, i was about to quit on devc++
i have a question how do i know when to use theses linkers and libraries in my program??
As was pointed out above by Clifford, the command
-libgdi32
is incorrect,it should be
-lgdi32
In answer to your bigger question, it can be challenging if you are
compiling code that someone else wrote. In general, looking at the
names of the header files that are included in your code, and the
functions that they contain can enable you to find the library you need.
Have your checked out the section in the thread "Please Read Before Posting
a Question" on the compile log, including headers, and linking libraries.
It might help provide some context.
Wayne
Thanks wayne