When attempting to run a file, I get the following:
c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\libmingw32.a(main.o):main.c|| undefined reference to `WinMain@16|
||=== Build finished: 1 errors, 0 warnings ===|
this is the build log:
-------------- Build: Debug in delta3d ---------------
mingw32-g++.exe -L..\..\..\..\..\Delta3D\REL-2.5.0\inc -LC:\Delta3D\REL-2.5.0\inc -o bin\Debug\delta3d.exe obj\Debug\main.o -lgdi32 -luser32 -lkernel32
c:/program files/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../libmingw32.a(main.o):main.c:(.text+0xd2): undefined reference to `WinMain@16
'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings
Will someone please tell me what I'm doing wrong? Ty in advance
EDIT: This happens even with a blank file
This a compiler question NOT a Code::Blocks Question. In the future ask compiler questions on a site that supports the Compiler.
Turning on Full Compiler Logging will help that site to help you.
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F
IIRC, you are missing the -mwindows option.
http://mingw-starter.blogspot.com/2008/02/mingw-sdl.html
Tim S.
You NEED to learn the difference between an Compiler and the IDE!!!!!!!!!
DO NOT PM ME!!!!!!!
You need to learn to search this site and the internet!
http://forums.next.codeblocks.org/index.php/topic,7906.0.html
Tim S.
You should create a GUI project, but you created a console program.
I downloaded the latest version of Code::Blocks and installed the compiler that came with the download, MinGW. I am having the same problem. "undefined reference to 'WinMain@16'. I went to the MinGW blog site and found a reference to requiring to turn on the "mwindows flag". I have attempted and was unable to find a "compiler flag" "mwindows" anywhere in the compiler settings provided through the installed Code::Blocks IDE.
I did find a readme file in the MinGW folder installed under Code::Blocks that had the following comment: "This edition of TDM-GCC is an unofficial replacement for the official GCC binaries distributed by the MinGW project; please note the following caveats: * TDM-GCC is not formally affiliated with or endorsed by the MinGW project. * No level of support for TDM-GCC is in any way guaranteed, although a best effort is made to fix bugs as they are found or forward them to GCC Bugzilla."
At this point I am at a loss. Since Code::Blocks provided an "unofficial" version of MinGW with the installation of the IDE, then it is somewhat an issue of the Code::Blocks IDE, not just a "compiler problem".
How do I fix this problem? Do I download the MinGW installer from SourceForge and attempt to install it under the Code::Blocks install? How do I re-integrate the newer install of MinGW compiler with the existing installation of Code::Blocks?
Let me add this comment: I am something of an experienced programmer from many years ago, attempting to re-learn C++ for a specific project that I want to do. The level of difficulty I am in finding a solution to this issue would likely be more than anyone starting out would overcome.
Quote from: colnelb on December 19, 2012, 01:32:39 AM
I downloaded the latest version of Code::Blocks and installed the compiler that came with the download, MinGW. I am having the same problem. "undefined reference to 'WinMain@16'. I went to the MinGW blog site and found a reference to requiring to turn on the "mwindows flag". I have attempted and was unable to find a "compiler flag" "mwindows" anywhere in the compiler settings provided through the installed Code::Blocks IDE.
Edit: "latest version of Code::Blocks" means nothing to me; post the version number!!
If you are trying to create a GUI program read this link.
http://forums.next.codeblocks.org/index.php/topic,7906.0.html (http://forums.next.codeblocks.org/index.php/topic,7906.0.html)
(Edit2: Look at the other linker option in the Image)
(Edit3: Project -> "Build Options" Tab: Linker Settings)
If you are NOT trying to create a GUI program; what are you trying to do?
Tim S.
I found something interesting. There is a problem with Code::Blocks in that it does not verify that the project/workspace folders/files are not read only before it calls the compiler and attempts to compile the project code. I spend days "going down the rabbit hole" researching the spurious error message seen in the subject line before I found that the restored project/workspace folder from a prior project had been restored as "read only". When the permissions were fixed, the project compiled without error. Check the permissions on your project/workspace folders and files.