Hey guys,
I'm trying to get my code to compile. I have 3 files: a header file, a cpp file for my main function and another cpp file for my other functions.
When I try to compile my cpp function file, I get the error Undefined reference to 'WinMain@16 and when I try to compile my main function file I get undefined reference to function name.
I am using code blocks.

Edited 4 Years Ago by daldrome: n/a

Probably something is wrong with your includes. In code::blocks, when you add a new file to a project you need to mark them to be included, otherwise you will get an error when you try to compile it. Add them to the project again, or include them manually. - Include the header and the cpp files in your main.cpp.

Edited 4 Years Ago by LRRR: n/a

Probably something is wrong with your includes. In code::blocks, when you add a new file to a project you need to mark them to be included, otherwise you will get an error when you try to compile it. Add them to the project again, or include them manually. - Include the header and the cpp files in your main.cpp.

I've tried that but now the console crashes on my first input. Any ideas?

I am also getting the same problem with 'WinMain@16'. I think that it is some intrinsic problem with the compiler library code itself, but I'm not sure. I'm not using any include files, and the error occurred during linking. Trust me, you do not want to see my code as it contains 5 template classes.
I am also using Code::Blocks.

Edited 4 Years Ago by jmsfruitison: n/a

I'm using MSVC6 and dhad similar issue. My C code has main(). But got the missing _WinMain16. I found that I had mistakenly created a Win32 App, not a Win32 Console App. In my Settings for stuff being passed to the compiler/linker you should see something like /subsystem:windows which really should be /subsystem:console.
Also in the Preprocessor definitions, not sure how much these are needed,
but for a WinApp, _WINDOWS is define. A Console app will have _CONSOLE defined.
Keven Miller Ranger1@3kranger.com

This article has been dead for over six months. Start a new discussion instead.