`WinMain@16' | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

`WinMain@16'

its been along time trying to fix this problem when making a c++ program using classes (header and cpp) i am getting this error (( undefined reference to `WinMain@16' )) i tried everything and just nothing is working //this problem happened to me before and i was solving it by restarting Code::block but now this is not working...

20th Jun 2017, 7:18 PM
SIGMA
SIGMA - avatar
11 Answers
+ 9
This error code sounds like when you are trying to compile an empty source code and the compiler can't find your main(). Same thoughts with @ChaoticDawg. But the code you provided doesn't reflect this error. :<
21st Jun 2017, 2:13 AM
Hatsy Rei
Hatsy Rei - avatar
+ 7
Well, if other compilers say the code is fine and your particular compiler or IDE is complaining, methinks it's time to get a new IDE lol. (Or reinstall it?) I really don't know what would fix the problem, because I run DevC++ (5.11), some VS, just not Code::Blocks.
21st Jun 2017, 2:13 PM
Hatsy Rei
Hatsy Rei - avatar
+ 5
You didn't #include <windows.h>?
20th Jun 2017, 8:04 PM
Karl T.
Karl T. - avatar
+ 4
Does your program have a main() function? Can you post your code?
20th Jun 2017, 7:52 PM
ChaoticDawg
ChaoticDawg - avatar
+ 4
@Chaotic is right. The best way for you to get help is to post your code.
20th Jun 2017, 8:15 PM
Manual
Manual - avatar
+ 2
@Hasty the code does have a main(), but if it was just copied and pasted into one cpp file would error (not necessarily this error). Windows with Codeblocks can give this error if the project type is wrong, or if the compiler settings are wrong with mingw.
21st Jun 2017, 2:19 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Ok, so the code itself is good. It does compile and run. So you most likely have a project, compiler or IDE settings issue. Can you create a new C++ console application like the built in "Hello, World" compile and run it? If so is your file configuration correct? See the project here: https://goo.gl/tQwq3t You can even download the project and try it that way.
20th Jun 2017, 10:29 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
So if your hello world console application is working fine (compiles, runs, and outputs Hello World) then what if any are the differences if you just had an empty main. Are there any other/different include statements? Is the signature of main the same? Was the project you created with the copied/downloaded code made as a console application? If you copy the code from the main.cpp into the hello world projects main.cpp and then add the other files to the project do you get the same issue?
21st Jun 2017, 3:01 AM
ChaoticDawg
ChaoticDawg - avatar
0
this code that i found in a lesson's comments.. https://justpaste.it/169sw it is on "more on classes"module>composition part 2>last one
20th Jun 2017, 9:47 PM
SIGMA
SIGMA - avatar
0
i tried to copy the code @chaoticdawg it didnt work also i downloaded it.same. //console applications working fine //when i compile it on the website it worked fine and showed the correct output ●so i should maybe reinstalling codeblocks?
21st Jun 2017, 2:51 AM
SIGMA
SIGMA - avatar
0
it is so messed up!
21st Jun 2017, 2:08 PM
SIGMA
SIGMA - avatar