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?

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.

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.

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

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.