Author Topic: Compiling Error  (Read 3797 times)

KingerTheThird

  • Guest
Compiling Error
« on: October 03, 2006, 07:09:06 pm »
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:

Code
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:

Code
#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

  • Guest
Re: Compiling Error
« Reply #1 on: October 03, 2006, 07:18:31 pm »
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

  • Guest
Re: Compiling Error
« Reply #2 on: October 03, 2006, 09:01:46 pm »
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

  • Guest
Re: Compiling Error
« Reply #3 on: October 03, 2006, 09:09:28 pm »
Ok. Well I should have read your post more carefully.....

Code: cpp
...

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

Should be:

Code: cpp
...

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

Notice the lower-case M. ;)

KingerTheThird

  • Guest
Re: Compiling Error
« Reply #4 on: October 04, 2006, 04:16:50 pm »
That worked, thanks.