Undefined reference to WinMain@16 - Codeblocks

前端 未结 2 1978
礼貌的吻别
礼貌的吻别 2021-01-28 21:50

I have read: undefined reference to `WinMain@16' & still don\'t understand my problem.

I had a program that was working. Added a class but had not implemented it

相关标签:
2条回答
  • 2021-01-28 22:14

    The problem is that your new project has been created as a Win32 GUI project, when it should have been created as a Console application. The former requires that a function with the signature int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) exists, while the latter requires one of the usual form taken for C or C++ projects, namely int main() or int main(char *argv[], int argc).

    Either create a new project of the console type and copy your code into it, or use the 'sticky-tape' solution, and change int main() to int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) You would also need to navigate to the project's properties and change the Build Target from GUI application to Console application - failing to do so would mean that you would not see any output, since you're using cout, which prints to stdout, which is shown by the console. This window is always available for a console application, but is only available for the Debug version of a GUI application.

    I reccomend doing it properly and creating a new project of the appropriate type, namely a Console application. :)

    0 讨论(0)
  • 2021-01-28 22:33

    Change the type of your application under your project settings to Console. WinMain16 is related to Windows graphical applications. I believe you do need to set a special preprocessor flag or include a library of some sort to get it to work properly if you keep it as a Windows graphical application, but in this case, the easiest fix would be to just get a console application.

    Also, maybe adding the -mwindows flag can help you.

    0 讨论(0)
提交回复
热议问题