Mingw linking problem

Hello, I'm having a problem running the MSDN's Learn to program windows module 1 program. It would seem the problematic part is the function signature.

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)

I can get this program to run from command prompt if I use the following command:

g++ Window.cpp -mwindows -o Windows.exe'

with the following function signature change:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR pCmdLine, int nCmdShow)

My question is why do I get an undefined reference to 'WinMain@16' when I use the one in the tutorial. I thought this just allowed a larger range of unicode? If someone could possibly tell me how to get the original code to run for mingw compiler that would be great.
Last edited on
EDIT: This may have to do with #defining UNICODE but I posted this reply in haste, prior to making sure. Take a look at this:

http://msdn.microsoft.com/en-us/library/windows/desktop/ff381407%28v=vs.85%29.aspx
Last edited on
Sorry I forgot to add the fact that I did add:
#ifndef UNICODE
#define UNICODE
#endif

to the top of the program.
Yes, shortly after posting I realized that this is probably not the issue myself, hence my sybsequent edit, sorry for my hasty reply.
MinGW does not support wWinMain entry point (also wmain does not work in MinGW), this is a known issue. Use WinMain even for Unicode programs.

Rebent versions of MinGW has added -municode switch, try it and see what happens.
Topic archived. No new replies allowed.