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.

Recommended Answers

All 4 Replies

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.

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.

Member Avatar for kevenm

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.