Simple Program Gone Wrong?

I wanted to display static text in a WinAPI window, but apparently I get these errors of which when it comes to google nothing related to fixing this. Here's the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <windows.h>
#include <string>
#include "resource.h"

using namespace std;

LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

HINSTANCE   hInstance;
HWND        Label1;
HANDLE      Label1Handle;


int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow) {

	MSG			msg;
	WNDCLASS	wc;
	HWND		hwnd = NULL;
	hInstance       = hThisInstance;

	wc.cbClsExtra		= 0;
	wc.cbWndExtra		= 0;
	wc.hbrBackground	= CreateSolidBrush(RGB(241, 241, 241));
	wc.hCursor			= LoadCursor(NULL, IDC_ARROW);
    wc.hIcon            = LoadIcon(hInstance, MAKEINTRESOURCE(MAIN_ICON));
	wc.hInstance      	= hThisInstance;
	wc.lpfnWndProc		= WinProc;
	wc.lpszClassName	= "Window";
	wc.lpszMenuName		= NULL;
	wc.style			= CS_HREDRAW | CS_VREDRAW;

 	if (!RegisterClass(&wc)) {
		MessageBox(NULL, "Error registering class", "ERROR", MB_OK);
		return 0;
	}

	hwnd = CreateWindow("Window",
						"Window",
						WS_OVERLAPPEDWINDOW,
						CW_USEDEFAULT,
						CW_USEDEFAULT,
						640,
						400,
						NULL,
						NULL,
						hThisInstance,
						NULL);

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

	while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return msg.wParam;
}

LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {

	switch (msg) {

        case WM_CREATE: {

        string LabelText1 = "Hello";

        Label1 = CreateWindowEx(0,
            "STATIC",
            "Some static text",
            WS_CHILD | WS_VISIBLE,
            25,
            125,
            150,
            20,
            hwnd,
            (HMENU)static_1,
            hInstance,
            0);

            SendDlgItemMessage(hwnd, static_1, WM_SETFONT, (WPARAM)CreateFont(12, 10, 0, 0, 500, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, TEXT("Terminal")), MAKELPARAM(TRUE, 0));

        } break;

        case WM_DESTROY: {
		    PostQuitMessage(0);
            return 0;
        } break;

        case WM_CLOSE: {
		    DestroyWindow(hwnd);
        } break;
    }

    return DefWindowProc(hwnd, msg, wParam, lParam);
}


and here is the error log:

1
2
3
4
5
6
7
8
9
10
C:\MinGW\lib\libmingw32.a(tlsthrd.o):tlsthrd.c|| undefined reference to `EnterCriticalSection@4'|
C:\MinGW\lib\libmingw32.a(tlsthrd.o):tlsthrd.c|| undefined reference to `LeaveCriticalSection@4'|
C:\MinGW\lib\libmingw32.a(tlsthrd.o):tlsthrd.c|| undefined reference to `EnterCriticalSection@4'|
C:\MinGW\lib\libmingw32.a(tlsthrd.o):tlsthrd.c|| undefined reference to `LeaveCriticalSection@4'|
C:\MinGW\lib\libmingw32.a(tlsthrd.o):tlsthrd.c|| undefined reference to `EnterCriticalSection@4'|
C:\MinGW\lib\libmingw32.a(tlsthrd.o):tlsthrd.c|| undefined reference to `LeaveCriticalSection@4'|
C:\MinGW\lib\libmingw32.a(tlsthrd.o):tlsthrd.c|| undefined reference to `LeaveCriticalSection@4'|
C:\MinGW\lib\libmingw32.a(tlsthrd.o):tlsthrd.c|| undefined reference to `DeleteCriticalSection@4'|
C:\MinGW\lib\libmingw32.a(tlsthrd.o):tlsthrd.c|| undefined reference to `InitializeCriticalSection@4'|
||=== Build finished: 9 errors, 0 warnings ===| 
Add -mwindows or link against libkernel32.a
Topic archived. No new replies allowed.