Undefined reference to "WinMain@16" in Code::Blocks?

I am using codeblocks and I just started to try Windows programming, and everytime I try to build it, I get the debugger message: undefined reference to WinMain@16. What am I doing wrong? This is what I have so far:

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
#include <windows.h>

INT WINAPI wWinMain(HINSTANCE hInst,
			HINSTANCE hPrevInst,
			LPWSTR lpCmdLine,
			INT nShowCmd)

{
	int nResult=MessageBox(NULL,
			"An example of Cancel,Retry,Continue",
			"Hello Message Box!",
			MB_ICONERROR|MB_ABORTRETRYIGNORE);

	switch(nResult)
	{
		case IDABORT:
			// 'Abort' was pressed
			break;
		case IDRETRY:
			// 'Retry' was pressed
			break;
		case IDIGNORE:
			// 'Ignore' was pressed
			break;
	}

	return 0;
}


So is there anything wrong? Or is just the compiler? I am kinda new to programming (2-3 months), so I assume I did something wrong. If it IS the compiler, than is there a different, free IDE or compiler I can use? Or how to fix it at least? Oh yeah and I entered win32 project for project type.

Last edited on
What type of project did you select?

Try win32 project and not console project
Last edited on
I did do win32 project.
1
2
3
4
5
6
7
8
9
#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
    LPSTR lpCmdLine, int nCmdShow)
{
    MessageBox(NULL, "Hi meganewbie!", "My Hero", MB_OK);
    return 0;
}


run that and see if you get the same error

make sure to choose win32 GUI project
Last edited on
Wow. That worked. I guess this forum is as helpful as I thought it was.
Topic archived. No new replies allowed.