News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Compiling Error

Started by KingerTheThird, October 03, 2006, 07:09:06 PM

Previous topic - Next topic

KingerTheThird

I'm having a problem getting a C++ file to build.  I made the source as simple as possible to try and get rid of all possibilities but I'm still having a problem.  When I go to build, the build log looks like:


Project   : AI Program 1 - Slide Puzzle
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\Kinger\My Documents\Code Blocks\AI\Slide Puzzle\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: SlideMain.cpp
Linking console executable: AI Project 1 - Slide Puzzle.exe
C:/Program Files/CodeBlocks/bin/../lib/gcc/mingw32/3.4.4/../../../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, 5 seconds)
0 errors, 0 warnings


It says there are no problems, but there is no executable file in the Slide Puzzle Directory.  The .objs directory appears with the SlideMain.o file in it.  Here is the source, as short as it is:


#include<iostream>
using namespace::std;

int Main()
{
  cout<<"Hello World!";
}


I'm a little curious as to why it's looking for WinMain@16 at all, this is going to be a console program.  Also, I opened a Win32 template and compiled that and it went together fine and made an Executable.

sethjackson

Go to: Project -> Properties -> Targets -> your_target_name -> Type. Set the type to console. :D

BTW

C:/Program Files/CodeBlocks/bin/../lib/gcc/mingw32/3.4.4/../../../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, 5 seconds)

When you have link errors I wouldn't call that a successfull build.......

KingerTheThird

Thanks for the help.

When I went into change the type is was already set to console.

Do I need to add the project under targets, or can I just leave it under Default?

sethjackson

Ok. Well I should have read your post more carefully.....

Code (cpp) Select

...

int Main()
{
  cout<<"Hello World!";
}


Should be:

Code (cpp) Select

...

int main()
{
  cout<<"Hello World!";
}


Notice the lower-case M. ;)

KingerTheThird