Undefined reference to WinMain (C++ Mingw)

后端 未结 3 527
梦如初夏
梦如初夏 2021-01-06 05:10

currently I am trying to make a windows application using c++. For compiling my program I use Mingw GCC. Btw I\'m on Windows 10. But as soon as I use int WINAPI wWinMa

3条回答
  •  离开以前
    2021-01-06 05:33

    undefined reference to `WinMain'

    It tries to find WinMain and failed. So you need use WinMain instead of wWinMain.

    Another possible issue is

    error: conflicting declaration of C function 'int WinMain(HINSTANCE, HINSTANCE, PWSTR, int)' int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow) ^~~~~~~ In file included from c:\mingw\include\windows.h:44:0, from test.cpp:5: c:\mingw\include\winbase.h:1263:14: note: previous declaration 'int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)' int APIENTRY WinMain (HINSTANCE, HINSTANCE, LPSTR, int);

    So you need use LPSTR instead of PWSTR.

    Then the entry point will like this:

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

    Above is ANSI version entry point.

提交回复
热议问题