0

hello all,
I moved a source file from a cgywin file to codeblocks. The file compiled and ran just fine in the cgywin environment. However, the same file under codeblocks complains about an undefined reference to winmain.

error:

Project   : Console application
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\jim\Desktop\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: counter2.cpp
Linking console executable: C:\Documents and Settings\jim\Desktop\console.exe
C:\Program Files\CodeBlocks\lib/libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 8 seconds)
0 errors, 0 warnings

what's causing this?

3
Contributors
3
Replies
4
Views
11 Years
Discussion Span
Last Post by Salem
0

hello all,

Hello :)

what's causing this?

Most probably you have selected a Windows GUI application instead of a Windows Console Application. A console application starts from a main function, and a GUI applications starts from a Winmain function. Because cygwin is a command line tool, and all the settings are done by hand you will not get that error.

0

OK, but the project is set for "console", and the the famous "hello world" program compiles within it's directory.

Is there something 'invisible" that comes along with a *.cpp that can switch the compiler to a different mode? I thought they were just raw text files.

0

> undefined reference to `WinMain@16'
It definitely thinks it is a GUI program somewhere along the line.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.